Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:ecsos:server
phpMyFAQ
phpMyFAQ-configpath.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File phpMyFAQ-configpath.patch of Package phpMyFAQ
Index: phpmyfaq/setup/index.php =================================================================== --- phpmyfaq.orig/setup/index.php +++ phpmyfaq/setup/index.php @@ -3,7 +3,7 @@ /** * The main phpMyFAQ Setup. * This script checks the complete environment, writes the database connection - * parameters into the file config/database.php and the configuration into the database. + * parameters into the file /etc/phpmyfaq/database.php and the configuration into the database. * This Source Code Form is subject to the terms of the Mozilla Public License, * v. 2.0. If a copy of the MPL was not distributed with this file, You can * obtain one at https://mozilla.org/MPL/2.0/. @@ -29,6 +29,7 @@ use phpMyFAQ\Strings; use phpMyFAQ\System; define('PMF_ROOT_DIR', dirname(__FILE__, 2)); +define('PMF_CONFIG_DIR', '/etc/phpmyfaq'); const PMF_SRC_DIR = PMF_ROOT_DIR . '/src'; const IS_VALID_PHPMYFAQ = null; @@ -53,8 +54,8 @@ session_start(); require PMF_ROOT_DIR . '/src/libs/autoload.php'; require PMF_ROOT_DIR . '/src/constants.php'; -require PMF_ROOT_DIR . '/config/constants.php'; -require PMF_ROOT_DIR . '/config/constants_elasticsearch.php'; +require PMF_CONFIG_DIR . '/constants.php'; +require PMF_CONFIG_DIR . '/constants_elasticsearch.php'; $loader = new ClassLoader(); $loader->add('phpMyFAQ', PMF_SRC_DIR); Index: phpmyfaq/setup/update.php =================================================================== --- phpmyfaq.orig/setup/update.php +++ phpmyfaq/setup/update.php @@ -48,12 +48,12 @@ $step = Filter::filterInput(INPUT_GET, ' $version = Filter::filterInput(INPUT_POST, 'version', FILTER_SANITIZE_SPECIAL_CHARS); $query = []; -if (!file_exists(PMF_ROOT_DIR . '/config/database.php')) { +if (!file_exists(PMF_CONFIG_DIR . '/database.php')) { $redirect = new RedirectResponse('./index.php'); $redirect->send(); } -$dbConfig = new DatabaseConfiguration(PMF_ROOT_DIR . '/config/database.php'); +$dbConfig = new DatabaseConfiguration(PMF_CONFIG_DIR . '/database.php'); ?> <!doctype html> @@ -206,8 +206,8 @@ if ($step == 2) { $updateMessages = []; // Backup of config/database.php - if (!copy(PMF_ROOT_DIR . '/config/database.php', PMF_ROOT_DIR . '/config/database.bak.php')) { - echo '<p class="alert alert-danger"><strong>Error:</strong> The backup file ../config/database.bak.php ' . + if (!copy(PMF_CONFIG_DIR . '/database.php', PMF_CONFIG_DIR . '/database.bak.php')) { + echo '<p class="alert alert-danger"><strong>Error:</strong> The backup file /etc/phpmyfaq/database.bak.php ' . 'could not be written. Please correct this!</p>'; } else { $checkDatabaseSetupFile = true; @@ -215,9 +215,9 @@ if ($step == 2) { } // Backup of config/ldap.php if exists - if (file_exists(PMF_ROOT_DIR . '/config/ldap.php')) { - if (!copy(PMF_ROOT_DIR . '/config/ldap.php', PMF_ROOT_DIR . '/config/ldap.bak.php')) { - echo '<p class="alert alert-danger"><strong>Error:</strong> The backup file ../config/ldap.bak.php ' . + if (file_exists(PMF_CONFIG_DIR . '/ldap.php')) { + if (!copy(PMF_CONFIG_DIR . '/ldap.php', PMF_CONFIG_DIR . '/ldap.bak.php')) { + echo '<p class="alert alert-danger"><strong>Error:</strong> The backup file /etc/phpmyfaq/ldap.bak.php ' . 'could not be written. Please correct this!</p>'; } else { $checkLdapSetupFile = true; @@ -228,10 +228,10 @@ if ($step == 2) { } // Backup of config/elasticsearch.php if exists - if (file_exists(PMF_ROOT_DIR . '/config/elasticsearch.php')) { - if (!copy(PMF_ROOT_DIR . '/config/elasticsearch.php', PMF_ROOT_DIR . '/config/elasticsearch.bak.php')) { + if (file_exists(PMF_CONFIG_DIR . '/elasticsearch.php')) { + if (!copy(PMF_CONFIG_DIR . '/elasticsearch.php', PMF_CONFIG_DIR . '/elasticsearch.bak.php')) { echo '<p class="alert alert-danger"><strong>Error:</strong> The backup file ' . - '../config/elasticsearch.bak.php could not be written. Please correct this!</p>'; + '/etc/phpmyfaq/elasticsearch.bak.php could not be written. Please correct this!</p>'; } else { $checkElasticsearchSetupFile = true; $updateMessages[] = 'A backup of your Elasticsearch configuration file has been made.'; @@ -546,7 +546,7 @@ if ($step == 3) { // // Remove backup files // - foreach (glob(PMF_ROOT_DIR . '/config/*.bak.php') as $filename) { + foreach (glob(PMF_CONFIG_DIR . '/*.bak.php') as $filename) { if (!unlink($filename)) { printf("<p class=\"alert alert-info\">Please remove the backup file %s manually.</p>\n", $filename); } Index: phpmyfaq/src/Bootstrap.php =================================================================== --- phpmyfaq.orig/src/Bootstrap.php +++ phpmyfaq/src/Bootstrap.php @@ -74,6 +74,13 @@ require 'constants.php'; require 'autoload.php'; // +// The config directory +// +if (!defined('PMF_CONFIG_DIR')) { + define('PMF_CONFIG_DIR', '/etc/phpmyfaq'); +} + +// // Check if multisite/multisite.php exist for Multisite support // if (file_exists(PMF_ROOT_DIR . '/multisite/multisite.php') && 'cli' !== PHP_SAPI) { @@ -84,13 +91,13 @@ if (file_exists(PMF_ROOT_DIR . '/multisi // Read configuration and constants // if (!defined('PMF_MULTI_INSTANCE_CONFIG_DIR')) { - define('PMF_CONFIG_DIR', PMF_ROOT_DIR . '/config'); // Single instance configuration + define('PMF_CONFIG_DIR', PMF_CONFIG_DIR); // Single instance configuration } else { define('PMF_CONFIG_DIR', PMF_MULTI_INSTANCE_CONFIG_DIR); // Multi instance configuration } // -// Check if config/database.php exist -> if not, redirect to installer +// Check if /etc/phpmyfaq/database.php exist -> if not, redirect to installer // if (!file_exists(PMF_CONFIG_DIR . '/database.php')) { $redirect = new RedirectResponse('./setup/index.php'); Index: phpmyfaq/src/phpMyFAQ/Instance/Client.php =================================================================== --- phpmyfaq.orig/src/phpMyFAQ/Instance/Client.php +++ phpmyfaq/src/phpMyFAQ/Instance/Client.php @@ -129,7 +129,7 @@ class Client extends Instance } /** - * Copies the config/constants.php file to a new client instance. + * Copies the /etc/phpmyfaq/constants.php file to a new client instance. * * @param string $destination Destination file * @throws Exception @@ -137,7 +137,7 @@ class Client extends Instance public function copyConstantsFile(string $destination): bool { return $this->fileSystem->copy( - $this->fileSystem->getRootPath() . '/config/constants.php', + $this->fileSystem->getRootPath() . '/etc/phpmyfaq/constants.php', $destination ); } Index: phpmyfaq/src/phpMyFAQ/Instance/Setup.php =================================================================== --- phpmyfaq.orig/src/phpMyFAQ/Instance/Setup.php +++ phpmyfaq/src/phpMyFAQ/Instance/Setup.php @@ -105,15 +105,15 @@ class Setup } /** - * Creates the file /config/database.php. + * Creates the file /etc/phpmyfaq/database.php. * * @param int[]|string[] $data Array with database credentials * @param string $folder Folder */ - public function createDatabaseFile(array $data, string $folder = '/config'): int|bool + public function createDatabaseFile(array $data, string $folder = '/etc/phpmyfaq'): int|bool { return file_put_contents( - $this->rootDir . $folder . '/database.php', + $this->ROOT . $folder . '/database.php', "<?php\n" . "\$DB['server'] = '" . $data['dbServer'] . "';\n" . "\$DB['port'] = '" . $data['dbPort'] . "';\n" . @@ -127,15 +127,15 @@ class Setup } /** - * Creates the file /config/ldap.php. + * Creates the file /etc/phpmyfaq/ldap.php. * * @param int[]|string[] $data Array with LDAP credentials * @param string $folder Folder */ - public function createLdapFile(array $data, string $folder = '/config'): int|bool + public function createLdapFile(array $data, string $folder = '/etc/phpmyfaq'): int|bool { return file_put_contents( - $this->rootDir . $folder . '/config/ldap.php', + $this->ROOT . $folder . '/ldap.php', "<?php\n" . "\$PMF_LDAP['ldap_server'] = '" . $data['ldapServer'] . "';\n" . "\$PMF_LDAP['ldap_port'] = '" . $data['ldapPort'] . "';\n" . @@ -147,15 +147,15 @@ class Setup } /** - * Creates the file /config/elasticsearch.php + * Creates the file /etc/phpmyfaq/elasticsearch.php * * @param int[]|string[] $data Array with Elasticsearch credentials * @param string $folder Folder */ - public function createElasticsearchFile(array $data, string $folder = '/config'): int|bool + public function createElasticsearchFile(array $data, string $folder = '/etc/phpmyfaq'): int|bool { return file_put_contents( - $this->rootDir . $folder . '/config/elasticsearch.php', + $this->ROOT . $folder . '/elasticsearch.php', "<?php\n" . "\$PMF_ES['hosts'] = ['" . implode("'], ['", $data['hosts']) . "'];\n" . "\$PMF_ES['index'] = '" . $data['index'] . "';\n", Index: phpmyfaq/src/phpMyFAQ/System.php =================================================================== --- phpmyfaq.orig/src/phpMyFAQ/System.php +++ phpmyfaq/src/phpMyFAQ/System.php @@ -325,7 +325,7 @@ class System */ public function checkInstallation(): bool { - return !is_file(PMF_ROOT_DIR . '/config/database.php'); + return !is_file(PMF_CONFIG_DIR . '/database.php'); } /** @@ -347,7 +347,7 @@ class System { $created = new DateTime(); $files = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator(PMF_ROOT_DIR), + new RecursiveDirectoryIterator(PMF_CONFIG_DIR), RecursiveIteratorIterator::SELF_FIRST ); @@ -355,11 +355,11 @@ class System 'created' => $created->format('Y-m-d H:i:sP'), ]; $ignoredFiles = [ - '/config/constants.php' => false, - '/config/constants_elasticsearch.php' => false, - '/config/database.php' => false, - '/config/elasticsearch.php' => false, - '/config/ldap.php' => false, + '/etc/phpmyfaq/constants.php' => false, + '/etc/phpmyfaq/constants_elasticsearch.php' => false, + '/etc/phpmyfaq/database.php' => false, + '/etc/phpmyfaq/elasticsearch.php' => false, + '/etc/phpmyfaq/ldap.php' => false, ]; $current = ''; @@ -371,7 +371,7 @@ class System (string) $file->getPath() ) ) { - $current = str_replace(PMF_ROOT_DIR, '', (string) $file->getPathname()); + $current = str_replace(PMF_CONFIG_DIR, '', (string) $file->getPathname()); if (isset($ignoredFiles[$current])) { continue; @@ -407,13 +407,13 @@ class System */ public function cleanFailedInstallationFiles(): void { - // Remove './config/database.php' file: no need of prompt anything to the user - if (file_exists(PMF_ROOT_DIR . '/config/database.php')) { - unlink(PMF_ROOT_DIR . '/config/database.php'); + // Remove '/etc/phpmyfaq/database.php' file: no need of prompt anything to the user + if (file_exists(PMF_CONFIG_DIR . '/database.php')) { + unlink(PMF_CONFIG_DIR . '/database.php'); } - // Remove './config/ldap.php' file: no need of prompt anything to the user - if (file_exists(PMF_ROOT_DIR . '/config/ldap.php')) { - unlink(PMF_ROOT_DIR . '/config/ldap.php'); + // Remove '/etc/phpmyfaq/ldap.php' file: no need of prompt anything to the user + if (file_exists(PMF_CONFIG_DIR . '/ldap.php')) { + unlink(PMF_CONFIG_DIR . '/ldap.php'); } } } Index: phpmyfaq/src/phpMyFAQ/Setup/Installer.php =================================================================== --- phpmyfaq.orig/src/phpMyFAQ/Setup/Installer.php +++ phpmyfaq/src/phpMyFAQ/Setup/Installer.php @@ -514,7 +514,7 @@ class Installer extends Setup } if (!$this->system->checkInstallation()) { - echo '<p class="alert alert-danger">The setup script found the file <code>config/database.php</code>. It ' . + echo '<p class="alert alert-danger">The setup script found the file <code>/etc/phpmyfaq/database.php</code>. It ' . 'looks like you\'re already running a version of phpMyFAQ. Please run the <a href="update.php">update' . ' script</a>.</p>'; System::renderFooter(); @@ -543,7 +543,7 @@ class Installer extends Setup System::renderFooter(); } - if (!is_readable(PMF_ROOT_DIR . '/config/database.php')) { + if (!is_readable(PMF_CONFIG_DIR . '/database.php')) { echo '<p class="alert alert-danger">It seems you never run a version of phpMyFAQ.<br>' . 'Please use the <a href="index.php">install script</a>.</p>'; System::renderFooter(); @@ -560,7 +560,7 @@ class Installer extends Setup if (!$databaseFound) { echo '<p class="alert alert-danger">It seems you\'re using an unsupported database version.<br>' . 'We found ' . ucfirst($database) . - '<br>' . 'Please use the change the database type in <code>config/database.php</code>.</p>'; + '<br>' . 'Please use the change the database type in <code>/etc/phpmyfaq/database.php</code>.</p>'; System::renderFooter(); } } @@ -900,14 +900,14 @@ class Installer extends Setup $email = Filter::filterInput(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL, ''); $permLevel = Filter::filterInput(INPUT_POST, 'permLevel', FILTER_SANITIZE_SPECIAL_CHARS, 'basic'); - $rootDir = $setup['rootDir'] ?? PMF_ROOT_DIR; + $configDir = $setup['configDir'] ?? PMF_CONFIG_DIR; $instanceSetup = new Setup(); - $instanceSetup->setRootDir($rootDir); + $instanceSetup->setRootDir($configDir); // Write the DB variables in database.php if (!$instanceSetup->createDatabaseFile($dbSetup)) { - echo '<p class="alert alert-danger"><strong>Error:</strong> Setup cannot write to ./config/database.php.' . + echo '<p class="alert alert-danger"><strong>Error:</strong> Setup cannot write to '.PMF_CONFIG_DIR.'/database.php.' . '</p>'; $this->system->cleanFailedInstallationFiles(); System::renderFooter(true); @@ -916,7 +916,7 @@ class Installer extends Setup // check LDAP is enabled if (extension_loaded('ldap') && !is_null($ldapEnabled) && count($ldapSetup)) { if (!$instanceSetup->createLdapFile($ldapSetup, '')) { - echo '<p class="alert alert-danger"><strong>Error:</strong> Setup cannot write to ./config/ldap.php.' . + echo '<p class="alert alert-danger"><strong>Error:</strong> Setup cannot write to '.PMF_CONFIG_DIR.'/ldap.php.' . '</p>'; $this->system->cleanFailedInstallationFiles(); System::renderFooter(true); @@ -926,15 +926,14 @@ class Installer extends Setup // check if Elasticsearch is enabled if (!is_null($esEnabled) && count($esSetup)) { if (!$instanceSetup->createElasticsearchFile($esSetup, '')) { - echo '<p class="alert alert-danger"><strong>Error:</strong> Setup cannot write to ' . - './config/elasticsearch.php.</p>'; + echo '<p class="alert alert-danger"><strong>Error:</strong> Setup cannot write to '.PMF_CONFIG_DIR.'/elasticsearch.php.' . '</p>'; $this->system->cleanFailedInstallationFiles(); System::renderFooter(true); } } // connect to the database using config/database.php - $dbConfig = new DatabaseConfiguration($rootDir . '/config/database.php'); + $dbConfig = new DatabaseConfiguration($configDir . '/database.php'); try { $db = Database::factory($dbSetup['dbType']); } catch (Exception $exception) { @@ -1050,8 +1049,8 @@ class Installer extends Setup $faqInstanceMaster->createMaster($faqInstance); // connect to Elasticsearch if enabled - if (!is_null($esEnabled) && is_file($rootDir . '/config/elasticsearch.php')) { - $esConfig = new ElasticsearchConfiguration($rootDir . '/config/elasticsearch.php'); + if (!is_null($esEnabled) && is_file($configDir . '/elasticsearch.php')) { + $esConfig = new ElasticsearchConfiguration($confiDir . '/elasticsearch.php'); $configuration->setElasticsearchConfig($esConfig);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor