Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
re-structured config, updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Nov 4, 2019
1 parent 1019a52 commit 4482b40
Show file tree
Hide file tree
Showing 17 changed files with 243 additions and 145 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
config.php
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,34 @@ This is fairly easy as long as you know how to create a new MySql-database (e.g.

1. Create an empty MySql database on your server, note down the DB host address, user name and password
2. Download the Sprudel files as `.zip` archive from this repository
3. Extract the contents of the `.zip` file into a new directory (e.g. `sprudel`)
4. Copy `config.php_template` and rename it to `config.php`
5. Edit your new `config.php` and insert the database's credentials (read comments in the file to understand what is what!)
6. Upload the `sprudel`-directory to your server (root-directory or somewhere else)
7. Access `<your installation folder>/install.php` through your browser (e.g. `yourdomain.com/sprudel/install.php`)
8. If everything is fine, Sprudel will tell you so.
9. Delete `install.php` from your server
10. **If you want to use the optional admin interface** (to view and delete any polls on your server via a web interface under `/admin`) you have to set this in the `config.php`, too! If you enable this feature, you'll have to **secure the** `admin` **directory, so it cannot be accessed publicly**! This process is different depending on the web server software you use. There are numerous tutorials about this online, e.g. for [Apache](https://www.tecmint.com/password-protect-apache-web-directories-using-htaccess/) or [Nginx](https://www.tecmint.com/password-protect-web-directories-in-nginx/). By the way, it is safe to rename the `admin` directory to anything less obvious!
11. Enjoy! :ok_hand:

## Customization
3. Extract the contents of the archive into a new directory (e.g. `sprudel` on your computer)
4. Edit `config/config.db.php` and insert the database's credentials (read comments in the file to understand what is what!)
5. Upload the `sprudel` directory to your web server (root-directory or somewhere else)
6. Access `<your installation folder>/install.php` through your browser (e.g. `yourdomain.com/sprudel/install.php`)
7. If everything is fine, Sprudel will tell you so
8. Delete `install.php` from your server
9. Enjoy! :ok_hand:

## Configuration and customization
### Features configuration
You can find the available features to turn on and off in `config/config.features.php`.
### Texts and labels
In the `config.php`, you can not only set up the database connection and functional configuration, but also *every text and label string used on the Sprudel website*! This means you could just adjust the texts to your needs or even translate the complete web interface to another language.
In `config/config.texts.php`, you can not only set up the database connection and functional configuration, but also *every text and label string used on the Sprudel website*! This means you could just adjust the texts to your needs or even translate the complete web interface to another language.
### Colors
At the top of the CSS stylesheet (`css/style.css`), you'll find a list of [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) you can change to customize colors and some other layout/design related things.

## Administration
### Poll administration interface
If you want to use the optional admin interface (to view and delete any polls on your server via a web interface under `/admin`) you have to enable this in `config/config.features.php`!
In this case, you'll have to **secure the** `admin` **directory, so it cannot be accessed publicly**! This process is different depending on the web server software you use. There are numerous tutorials about this online, e.g. for [Apache](https://www.tecmint.com/password-protect-apache-web-directories-using-htaccess/) or [Nginx](https://www.tecmint.com/password-protect-web-directories-in-nginx/). By the way, it is safe to rename the `admin` directory to anything less obvious!
### Automatic deletion of inactive polls
You can set up a certain number of days in the `config.features.php` to mark the maximum age of an **inactive** poll ( *inactive* as in: no new answers and comments). Sprudel comes with a cleanup script (`cleanup.php`) that you can set up to be executed periodically via a cronjob, e.g.
`0 0 1 * * /usr/bin/php /var/www/html/sprudel/cleanup.php`
The cleanup script will then delete all inactive polls that became too old.

## Contribution
I don't actually feel at home in PHP, but I chose this language anyway because it's still the most widely used backend scripting language and already installed on most web servers. It's always nice not to have to install an additional backend ecosystem on your server just because you want to try a new web app.
I tried hard to make this as bulletproof and tidy as possible, but I bet my thumbs on that it doesn't always follow best practice. If you have any suggestions on possibly missing features, **write an issue**! If you feel like improving the code of this app, send a (well documented) **pull request**! If you just like Sprudel as it is, let me know by donating this repo a star.
I tried hard to make this as bulletproof and tidy as possible, but I bet my thumbs on that it doesn't always follow best practice. If you have any suggestions for additional features or run into problems setting up Sprudel, **write an issue**! If you feel like improving the code of this app, send a (well documented) **pull request**! If you just like Sprudel as it is, let me know by donating this repo a star.

## Attribution of used third-party software/media
Sprudel makes use of the following software/media and says **Thank you!** to:
Expand Down
4 changes: 0 additions & 4 deletions admin/htaccess_template

This file was deleted.

1 change: 0 additions & 1 deletion admin/htpasswd_template

This file was deleted.

3 changes: 2 additions & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
require_once '../db.php';
require_once "../db.php";
require_once "../config/config.features.php";

if (SPR_ADMIN_INTERFACE != 1){
header("Location: ../404.php");
Expand Down
4 changes: 2 additions & 2 deletions cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
exit();
}
chdir(__DIR__);
require_once "config.php";
require_once "config/config.features.php";
require_once "db.php";

$db = new DB;
Expand All @@ -19,7 +19,7 @@
echo "***********************" . PHP_EOL;
echo PHP_EOL;
echo "This will delete every poll that was inactive" . PHP_EOL . "since " . $minDate . " (for at least " . SPR_DELETE_AFTER . " days)." . PHP_EOL;
echo "You may change this value in config.php" . PHP_EOL;
echo "You may change this value in 'config/config.features.php'" . PHP_EOL;
echo PHP_EOL;

//get IDs of polls to delete
Expand Down
94 changes: 0 additions & 94 deletions config.php_template

This file was deleted.

27 changes: 27 additions & 0 deletions config/config.all.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

////////////////////////////////////////
//// ////
//// DON'T TOUCH THIS FILE !!! ////
//// ////
//// (No, really, don't! ////
//// If you are here to ////
//// set up your database ////
//// connection, have a look ////
//// at "config.db.php" !) ////
//// ////
////////////////////////////////////////

// include database config
require_once 'config.db.php';

// include features config
require_once 'config.features.php';

// include texts and labels config
require_once 'config.texts.php';

// include internal config
require_once 'config.internal.php';

?>
15 changes: 15 additions & 0 deletions config/config.db.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

//////////////////////////////////////////
//// ////
//// DATABASE CONNECTION ////
//// (you HAVE TO fill this in!) ////
//// ////
//////////////////////////////////////////

define('SPR_DB_NAME', 'db_sprudel'); // Database name
define('SPR_DB_SERVER', 'localhost'); // Database server address ('localhost' in most cases)
define('SPR_DB_USERNAME', 'web'); // Replace 'web' by the username to access database
define('SPR_DB_PASSWORD', 'web'); // Replace 'web' by the password to access database

?>
30 changes: 30 additions & 0 deletions config/config.features.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/////////////////////////////////////////////
//// ////
//// FUNCTIONAL CONFIGURATION ////
//// (switch stuff on and off) ////
//// ////
/////////////////////////////////////////////

// Turn on(1)/off(0) admin interface
// (read README.md for further instructions!)
define('SPR_ADMIN_INTERFACE', 1);

// Turn on(1)/off(0) admin link functionality (recommended)
define('SPR_ADMIN_LINKS', 1);

// Lifespan (in days) of inactive polls
// (read README.md for further instructions!)
define('SPR_DELETE_AFTER', 30);

// Header Logo
// (set to 1 if you want to show header logo, 0 otherwise)
define('SPR_SHOW_HEADER_LOGO', 1);

// Footer Text and Link
// (Insert 0 if you want to remove the GitHub footer link.
// Hot tipp of the week: Consider being nice and leaving it there!)
define('SPR_SHOW_FOOTER_LINK', 1);

?>
19 changes: 19 additions & 0 deletions config/config.internal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/////////////////////////////////
//// ////
//// SOME INTERNAL STUFF ////
//// (Don't touch this!) ////
//// ////
/////////////////////////////////

// figure out the base URL
if (!(PHP_SAPI === 'cli')){
$doc_root = preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']);
$protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
$domain = $_SERVER['SERVER_NAME'];
$base_url = preg_replace("!^${doc_root}!", '', dirname(__DIR__));
define('SPR_BASE_URL', "${protocol}://${domain}${base_url}/");
}

?>
115 changes: 115 additions & 0 deletions config/config.texts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php

////////////////////////////////////////////////
//// ////
//// USER INTERFACE TEXTS AND STRINGS ////
//// (go wild, change everything!) ////
//// ////
////////////////////////////////////////////////

//// GENERAL ////

// Title of the HTML page
define('SPR_HTML_PAGE_TITLE', 'Sprudel');
// Title shown in index header area
define('SPR_INDEX_TITLE', 'Sprudel');
// Subtitle shown in index header area
define('SPR_INDEX_SUBTITLE', 'scheduling polls');
// Warning message to show if JavaScript is disabled
define('SPR_NO_JS_MSG', 'Please enable JavaScript in your browser and reload this page.');

//// CREATE NEW POLL / LANDING PAGE ////

// Heading for index / new poll page
define('SPR_NEW_FORM_HEADING', 'Create a new poll ...');
// Label for poll title field
define('SPR_NEW_FORM_TITLE', 'Title');
// Placeholder for poll title field
define('SPR_NEW_FORM_TITLE_PLACEHOLDER', 'What about a title for your poll?');
// Label for poll description / details field
define('SPR_NEW_FORM_DETAILS', 'Description');
// Placeholder for poll details field
define('SPR_NEW_FORM_DETAILS_PLACEHOLDER', 'Your participants may also like a short description of what this poll is all about, right?');
// Label for poll answer options
define('SPR_NEW_FORM_OPTIONS', 'Options');
// Placeholder for poll first poll answer / option
define('SPR_NEW_FORM_OPTIONS_PLACEHOLDER', 'Type whatever you want or pick a date!');
// Label for poll admin links
define('SPR_NEW_FORM_ADMIN', 'Admin Link');
// Label for poll admin links checkbox
define('SPR_NEW_FORM_ADMIN_CHECKBOX', 'Deleting poll/entries only with admin link');
// Text for poll submit button
define('SPR_NEW_FORM_SUBMIT', 'Create poll!');

//// POLL VIEW ////

// Placeholder for poll entry name input field
define('SPR_POLL_NAME', 'Your name?');
// Save poll entry button text
define('SPR_ENTRY_SAVE', 'Save');
// Confirmation text when removing an entry (automatically followed by name)
define('SPR_REMOVE_CONFIRM', 'Do you really want to remove');
// Confirmation text when deleting a poll
define('SPR_DELETE_POLL_CONFIRM', 'Do you really want to delete this poll?');
// Label for public link in header
define('SPR_PUBLIC_LINK', 'Public link:');
// Description for public link in header
define('SPR_PUBLIC_LINK_DESC', 'Give this public link to the participants of your poll!');
// Label for admin link in header
define('SPR_ADMIN_LINK', 'Admin link:');
// Description for admin link in header
define('SPR_ADMIN_LINK_DESC', 'Save this admin link, you need it to manage your poll!');
// Copy link button tooltip
define('SPR_LINK_COPY_TITLE', 'Copy link to clipboard!');
// Copy url error text
define('SPR_URL_COPY_ERROR', 'Error copying URL. Please copy it manually!');
// Control button text: Trigger mini view
define('SPR_POLL_CONTROL_MINI_VIEW', 'Mini View');
// Control button text: Trigger normal view
define('SPR_POLL_CONTROL_NORMAL_VIEW', 'Normal View');
// Control button text: Delete poll
define('SPR_POLL_CONTROL_DELETE', 'Delete Poll');
// Poll results legend: yes
define('SPR_POLL_RESULTS_YES', 'Yes:');
// Poll results legend: maybe
define('SPR_POLL_RESULTS_MAYBE', 'Maybe:');
// Poll results legend: no
define('SPR_POLL_RESULTS_NO', 'No:');
// Comments section heading
define('SPR_COMMENT_HEADING', 'Comments');
// No comments message
define('SPR_COMMENT_NONE', 'No comments, yet.');
// Comment name field label
define('SPR_COMMENT_NAME', 'Your name');
// Comment text field label
define('SPR_COMMENT_TEXT', 'Your comment');
// Comment submit button text
define('SPR_COMMENT_SUBMIT', 'Save');
// Poll not found / invalid URL text
define('SPR_404', 'Whoops... did you use a wrong link?');
// Info about how long inactive polls are stored
// (leave "n" as a placeholder for the number of days - it will be replaced automatically!)
define('SPR_LIFESPAN', 'Attention! Inactive polls will be deleted automatically after n days!');

//// DATEPICKER STRINGS ////

// Datepicker translation for monday
define('SPR_DATEPICKER_MONDAY', 'Monday');
// Datepicker translation for Tuesday
define('SPR_DATEPICKER_TUESDAY', 'Tuesday');
// Datepicker translation for Wednesday
define('SPR_DATEPICKER_WEDNESDAY', 'Wednesday');
// Datepicker translation for Thursday
define('SPR_DATEPICKER_THURSDAY', 'Thursday');
// Datepicker translation for Friday
define('SPR_DATEPICKER_FRIDAY', 'Friday');
// Datepicker translation for Saturday
define('SPR_DATEPICKER_SATURDAY', 'Saturday');
// Datepicker translation for Sunday
define('SPR_DATEPICKER_SUNDAY', 'Sunday');
// Datepicker locale ISO-code
// (change to de-DE for German, fr-FR for French, etc.)
define('SPR_DATEPICKER_LANG', 'en-US');
// Datepicker date format
// (you can use and combine yyyy, yy, mm, m, dd, d)
define('SPR_DATEPICKER_FORMAT', 'yyyy-mm-dd');
Loading

0 comments on commit 4482b40

Please sign in to comment.