]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
first steps in setup file
authorBanana <mail@bananas-playground.net>
Sun, 8 Aug 2021 08:01:28 +0000 (10:01 +0200)
committerBanana <mail@bananas-playground.net>
Sun, 8 Aug 2021 08:01:28 +0000 (10:01 +0200)
CHANGELOG
webclient/config/config.php.default
webclient/index.php
webclient/setup.php [new file with mode: 0644]

index 1b25a026b585518ae00425e53e78fd9e66908c29..90c527799e2f7c9717f42561724f8486ebca1cf7 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 1.x - Rrajigar Mine
        * Fixed install sql file.
        * New field: artists - lookupmultiple field
+       * Added setup file. See setup.txt for more details
 
 1.2 - NyLeve's Falls 20210717
        * Updated requirements information
index 486851a0424f12186badc471532e35f30575422b..aa32af9ac7393025880a3d9bbdd982bfeffb0087 100644 (file)
  */
 
 # set to true if you need debug messages in error log file
-define('DEBUG',true);
+define('DEBUG',false);
 # set to ture if you need query log messages in error log file.
-define('QUERY_DEBUG',true);
+define('QUERY_DEBUG',false);
 
 # timezone settings
-define('TIMEZONE','Europe/Berlin');
+define('TIMEZONE','~timezone~');
 
 # path settings
-define('PATH_ABSOLUTE','/home/some/path/bibliotheca/webclient');
+define('PATH_ABSOLUTE','~pathabsolute~');
 define('PATH_SYSTEMOUT',PATH_ABSOLUTE.'/systemout');
 define('PATH_STORAGE',PATH_ABSOLUTE.'/storage');
 define('PATH_WEB_STORAGE','storage');
 
 # database config
-define('DB_HOST','127.0.0.1');
-define('DB_USERNAME','user');
-define('DB_PASSWORD','test');
-define('DB_NAME','bibliotheca');
-define('DB_PREFIX','bib'); # a _ is added automatically as separation
+define('DB_HOST','~dbhost~');
+define('DB_USERNAME','~dbuser~');
+define('DB_PASSWORD','~dbpassword~');
+define('DB_NAME','~dbname~');
+define('DB_PREFIX','~dbprefix~'); # a _ is added automatically as separation
 
 ## theme support
 # fallback is default theme
index beae986af22d579450c1fcd29b0b2f0e74a85895..d379624ed3bef7df9792e2c23139144e2359465c 100644 (file)
@@ -25,7 +25,6 @@ ini_set('error_reporting',-1); // E_ALL & E_STRICT
 # check request
 $_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
 if(!empty($_urlToParse)) {
-       # see http://de2.php.net/manual/en/regexp.reference.unicode.php
        if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) {
                die('Malformed request. Make sure you know what you are doing.');
        }
diff --git a/webclient/setup.php b/webclient/setup.php
new file mode 100644 (file)
index 0000000..8456b60
--- /dev/null
@@ -0,0 +1,144 @@
+<?php
+/**
+ * Bibliotheca
+ *
+ * Copyright 2018-2021 Johannes Keßler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+mb_http_output('UTF-8');
+mb_internal_encoding('UTF-8');
+ini_set('error_reporting',-1); // E_ALL & E_STRICT
+ini_set('display_errors',true);
+date_default_timezone_set('Europe/Berlin');
+
+# check request
+$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
+if(!empty($_urlToParse)) {
+       if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) {
+               die('Malformed request. Make sure you know what you are doing.');
+       }
+}
+
+$TemplateData = array();
+
+$configStep = 'ready';
+$configFile = './config/config.php';
+if(file_exists($configFile) && is_readable($configFile)) {
+       $configStep = 'config';
+}
+
+switch($configStep) {
+       case 'config':
+               $TemplateData['headline'] = '1. Main config file';
+               $TemplateData['body'] = 'More special options can be directly edited in the config files themself. Only the basics are covered here.';
+               $TemplateData['footer'] = 'Next - additional tools';
+
+               $data = array(
+                       'timezone' => 'Europe/Berlin'
+               );
+
+               $TemplateData['bodyForm'] = stepConfig($data);
+       break;
+
+       case 'ready':
+       default:
+               $TemplateData['headline'] = 'Complete';
+               $TemplateData['body'] = 'All done. This file is now gone. To restart the setup remove all non .default config files and upload the setup.php file again.';
+               $TemplateData['bodyForm'] = '';
+               $TemplateData['footer'] = 'cya';
+}
+
+?>
+<!DOCTYPE html>
+<html>
+<head>
+       <meta charset="UTF-8" />
+       <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+       <meta name="author" content="https://www.bananas-playground.net/projekt/bibliotheca" />
+       <title>Setup - Bibliotheca</title>
+</head>
+<body>
+       <header>
+               <h1><?php echo $TemplateData['headline']; ?></h1>
+       </header>
+       <main>
+               <p><?php echo $TemplateData['body']; ?></p>
+               <form method="post" action="">
+                       <?php echo $TemplateData['bodyForm']; ?>
+                       <p><button type="submit" name="submitForm">Save</button></p>
+               </form>
+       </main>
+       <footer>
+               <p><?php echo $TemplateData['footer']; ?></p>
+               <p>&copy; 2018 - <?php echo date('Y'); ?> <a href="https://www.bananas-playground.net/projekt/bibliotheca/" target=_blank>Bibliotheca</a></p>
+       </footer>
+</body>
+</html>
+<?php
+/**
+ * all the "methods" for the steps.
+ * KISS
+ */
+
+/**
+ * Step config
+ *
+ * @param array $data
+ * @return string
+ */
+function stepConfig(array $data): string {
+       $timeZones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
+       $timeZoneOptions = '';
+       foreach ($timeZones as $tz) {
+               $selected = '';
+               if($tz == $data['timezone']) {
+                       $selected = 'selected="selected"';
+               }
+               $timeZoneOptions .= "<option ".$selected." value='".$tz."'>".$tz."</option>";
+       }
+       $absPath = getcwd();
+
+       return <<<RET
+<p>
+       Select your timezone<br />
+       <select name="timezone">
+               {$timeZoneOptions}
+       </select>
+</p>
+<p>
+       The absolute path to this installation on your webspace. Current <b>{$absPath}</b> should be the right one.<br />
+       <input type="text" name="pathabsolute" value="" size="50">
+</p>
+<p>
+       Database Hostname<br />
+       <input type="text" name="dbhost" value="">
+</p>
+<p>
+       Database User<br />
+       <input type="text" name="dbuser" value="">
+</p>
+<p>
+       Database Password for the given user<br />
+       <input type="text" name="dbpassword" value="">
+</p>
+<p>
+       Database name<br />
+       <input type="text" name="dbname" value="">
+</p>
+<p>
+       Database table prefix. Default is <b>bib</b>. A _ is added automatically.<br />
+       <input type="text" name="dbprefix" value="">
+</p>
+RET;
+}