diff --git a/README.md b/README.md
index 799259f0f..4d96fcbce 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,10 @@ To install loklak with Docker please refer to the loklak [Docker installation re
Please read how to deploy to [Heroku here](/docs/HEROKU.md)
+## How do I install Engelsystem on my local machine from bash script
+
+Please check out [the documentation here](/docs/INSTALLATION_BASH_SCRIPT.md).
+
## Report Bugs
Please report bugs and feature requests here https://github.com/engelsystem/engelsystem/issues
diff --git a/config/config-sample.default.php b/config/config-sample.default.php
index 744fef25a..e8e5a25e3 100644
--- a/config/config-sample.default.php
+++ b/config/config-sample.default.php
@@ -25,9 +25,11 @@
// define('CRYPT_ALG', '$1'); // MD5
// define('CRYPT_ALG', '$2y$13'); // Blowfish
// define('CRYPT_ALG', '$5$rounds=5000'); // SHA-256
-define('CRYPT_ALG', '$6$rounds=5000'); // SHA-512
+if (!defined('CRYPT_ALG'))
+ define('CRYPT_ALG', '$6$rounds=5000'); // SHA-512
-define('MIN_PASSWORD_LENGTH', 8);
+if (!defined('MIN_PASSWORD_LENGTH'))
+ define('MIN_PASSWORD_LENGTH', 8);
// When angels should specify a T - shirt size when registering or in their profile , set to true :
$enable_tshirt_size = true;
@@ -49,8 +51,8 @@
// voucher calculation
$voucher_settings = array(
- "initial_vouchers" => 2,
- "shifts_per_voucher" => 1
+ "initial_vouchers" => 2,
+ "shifts_per_voucher" => 1
);
// weigh every shift the same
@@ -60,17 +62,17 @@
$api_key = "";
// MySQL-Connection Settings
-$config = array(
- 'host' => "localhost",
- 'user' => "username_here",
- 'pw' => "password_here",
- 'db' => "database_name_here"
-);
-
+$DB_HOST = "localhost";
+$DB_USER = "username_here";
+$DB_PASSWORD = "password_here";
+$DB_NAME = "database_name_here";
/** reCaptcha Settings
* Visit http://www.google.com/recaptcha/admin#whyrecaptcha for generating reCaptcha keys for your website.
*/
-define('capflg', ''); // Set reCaptch enalble or disable. true = enable , false = disable.
-define('CAPTCHA_KEY_PUBLIC', ''); // Public/Data-site key
-define('CAPTCHA_KEY_PRIVATE', ''); // Private/Secret Key
+if (!defined('capflg'))
+ define('capflg', ''); // Set reCaptch enalble or disable. true = enable , false = disable.
+if (!defined('CAPTCHA_KEY_PUBLIC'))
+ define('CAPTCHA_KEY_PUBLIC', ''); // Public/Data-site key
+if (!defined('CAPTCHA_KEY_PRIVATE'))
+ define('CAPTCHA_KEY_PRIVATE', ''); // Private/Secret Key
?>
diff --git a/db/update.sql b/db/update.sql
index f0cb1dfd6..71931a86c 100644
--- a/db/update.sql
+++ b/db/update.sql
@@ -66,7 +66,8 @@ CREATE TABLE IF NOT EXISTS `Settings` (
`event_start_date` int(11) DEFAULT NULL,
`event_end_date` int(11) DEFAULT NULL,
`teardown_end_date` int(11) DEFAULT NULL,
- `event_welcome_msg` varchar(255) DEFAULT NULL
+ `event_welcome_msg` varchar(255) DEFAULT NULL,
+ `table_migrated` int(11) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
-- Added privilege for Admin Settings
@@ -82,3 +83,10 @@ INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES (337, -4
-- Added privelege for the Create Groups page
INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (41, 'admin_cgroups', 'Create new groups');
INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES (339, -4, 41);
+
+-- ------------------------------------------------------------------------------------
+-- Added Privilege for install page.
+INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (42, 'install', 'Install Engelsystem');
+
+
+
diff --git a/docs/CONFIGURATION_DOCUMENT_ROOT.md b/docs/CONFIGURATION_DOCUMENT_ROOT.md
new file mode 100644
index 000000000..053b7a155
--- /dev/null
+++ b/docs/CONFIGURATION_DOCUMENT_ROOT.md
@@ -0,0 +1,25 @@
+# Instructions to configure document root in ubuntu
+
+We must make sure to point our apache2 document root to the Engelsystem directory to prevent any user from accessing anything other than the public/ directory for security reasons. Do this by modifying the apache2 configuration file
+
+### Changing apache2 document root
+
+The default document root is set in the 000-default.conf file that is under /etc/apache2/sites-available folder.
+
+$ ```sudo nano /etc/apache2/sites-available/000-default.conf```
+
+While the file is opened change DocumentRoot /var/www/ with your new folder
+e.g DocumentRoot /var/www/html/engelsystem/public
+
+or you can execute the following command in your terminal
+
+$ ```sudo sed -i -e 's/DocumentRoot \/var\/www\/html/DocumentRoot \/var\/www\/html\/engelsystem\/public/g' /etc/apache2/sites-available/000-default.conf```
+
+### Set the right Apache folder Permissions
+
+$ ```sudo chown -R www-data /var/www/html/engelsystem/```
+
+### Restart Apache
+$ ``` sudo service apache2 restart ```
+
+After following these steps engelsystem can be viewed at **localhost/ or at http://[i.p.address]**
diff --git a/docs/INSTALLATION_BASH_SCRIPT.md b/docs/INSTALLATION_BASH_SCRIPT.md
new file mode 100644
index 000000000..645222b53
--- /dev/null
+++ b/docs/INSTALLATION_BASH_SCRIPT.md
@@ -0,0 +1,18 @@
+# INSTALLATION OF ENGELSYSTEM
+
+- Engelsystem can be installed in your local server through install.sh file.
+
+#### Steps to setup engelsystem using install.sh
+
+### Step 1
+- download [install.sh](/install.sh).
+
+### Step 2
+- change the permissions of `install.sh`
+- `$ chmod +x install.sh`
+
+### Step 3
+- Execute the file
+- ` $ ./install.sh`
+
+- Now engelsystem is successfully installed.
diff --git a/docs/INSTALLATION_FIVE_MINUTES.md b/docs/INSTALLATION_FIVE_MINUTES.md
new file mode 100644
index 000000000..26e810837
--- /dev/null
+++ b/docs/INSTALLATION_FIVE_MINUTES.md
@@ -0,0 +1,26 @@
+# Five Minute Installation of Engelsystem
+### Prerequisites
+Please check out the docs for more information [the documentation here](/docs/).
+
+ 1.1 PHP 5.4.x (cgi-fcgi)
+ 1.2 MySQL-Server 5.5.x pr MariaDB
+ 1.3 Webserver ( Apache/Nginx/lighttpd)
+
+### Step 1: Download or Clone the repository
+- ```$ git clone --recursive https://github.com/fossasia/engelsystem.git```
+
+### Step 2: Create a Mysql Database
+- Using the MySQL Client
+- ```$ mysql -u root -p```
+- ```mysql> CREATE DATABASE engelsystem;```
+
+### Step 3: Set up config.php
+- Go to engelsystem/config and copy the default config-sample into config.php. Modify the new file to match your MySQL credentials so that the system could access the database on the localserver.
+
+### Step 4: Upload the files
+-Move the app to your /var/www/html/ directory by typing ```sudo mv ./engelsystem /var/www/html``` and we can view engelsystem on localhost/ after configuring document root [documentation here](/docs/CONFIGURATION_DOCUMENT_ROOT.md)
+
+### Step 5: Run the Install Script
+- Visit localhost/ on your browser you will be redirected to install script.
+
+Once you have filled the information and clicked install engelsystem. We are redirected to login page where we can login with the credentials with admin rights.
diff --git a/docs/INSTALLATION_LOCAL.md b/docs/INSTALLATION_LOCAL.md
index 3f0ca3f03..3e219afaf 100644
--- a/docs/INSTALLATION_LOCAL.md
+++ b/docs/INSTALLATION_LOCAL.md
@@ -24,12 +24,6 @@
** CREATE DATABASE engelsystem;**
-** use engelsystem;**
-
-** source \[path to engelsystem\]/engelsystem/db/install.sql;**
-
-** source \[path to engelsystem\]/engelsystem/db/update.sql;**
-
** exit;**
* Go to **engelsystem/config** and copy the default config-sample into config.php. Modify the new file to match your MySQL credentials so that the system could access the database on the localserver.
diff --git a/docs/INSTALLATION_SERVER.md b/docs/INSTALLATION_SERVER.md
index c58563455..fe1c4826c 100644
--- a/docs/INSTALLATION_SERVER.md
+++ b/docs/INSTALLATION_SERVER.md
@@ -18,8 +18,6 @@
* Next, configure your Engelsystem database:
-
-
1. Create a database for the Engelsystem (give any name to it)
2. Open phpMyAdmin on the server to create tables in the database
@@ -29,7 +27,6 @@
4. Import the “install.sql” and “update.sql” to finish configuring the database for the Engelsystem
-
* We must make sure to point our Apache document root to the Engelsystem directory to prevent any user from accessing anything other than the public/ directory for security reasons. Do this by modifying the Apache configuration file using the SSH access and edit the following file:
\#vim /var/cpanel/userdata/USERNAME/DOMAINNAME.COM
@@ -47,7 +44,7 @@
\# service httpd restart
The changes will be permanently updated. Check your site for reflecting changes. For more help on changing the documentroot in CPanel, please visit [here](http://tecadmin.net/how-to-change-document-root-of-primary-domain-in-cpanel/) .
-## Setting up Captcha
+## Setting up Captcha
* For setting up captcha for the online server, we need to signup for reCaptcha API keys. The keys are unique to the domain or domains you specify, and their respective sub-domains. Specifying more than one domain could come in handy in the case that you serve your website from multiple top level domains (for example: yoursite.com, yoursite.net).
* Visit the link,http://www.google.com/recaptcha/admin#whyrecaptcha , and sign up for the reCaptcha API keys.
diff --git a/includes/controller/guest_credits_controller.php b/includes/controller/guest_credits_controller.php
index d4be03d9a..c475a7deb 100644
--- a/includes/controller/guest_credits_controller.php
+++ b/includes/controller/guest_credits_controller.php
@@ -6,4 +6,4 @@ function credits_title() {
function guest_credits() {
return template_render('../templates/guest_credits.html', array());
}
-?>
\ No newline at end of file
+?>
diff --git a/includes/controller/user_shifts_controller.php b/includes/controller/user_shifts_controller.php
index 64ef93c63..9f1bec3c8 100644
--- a/includes/controller/user_shifts_controller.php
+++ b/includes/controller/user_shifts_controller.php
@@ -1024,4 +1024,4 @@ function make_select($items, $selected, $name, $title = null) {
$html .= '' . "\n";
return $html;
}
-?>
\ No newline at end of file
+?>
diff --git a/includes/engelsystem_provider.php b/includes/engelsystem_provider.php
index f2957a153..f05c711a0 100644
--- a/includes/engelsystem_provider.php
+++ b/includes/engelsystem_provider.php
@@ -30,6 +30,7 @@
require_once realpath(__DIR__ . '/../includes/model/News_model.php');
require_once realpath(__DIR__ . '/../includes/model/Questions_model.php');
require_once realpath(__DIR__ . '/../includes/model/WelcomeMessage_model.php');
+require_once realpath(__DIR__ . '/../includes/model/import_model.php');
require_once realpath(__DIR__ . '/../includes/view/AngelTypes_view.php');
require_once realpath(__DIR__ . '/../includes/view/Questions_view.php');
@@ -82,6 +83,7 @@
if (file_exists(realpath(__DIR__ . '/../config/config.php')))
require_once realpath(__DIR__ . '/../config/config.php');
+require_once realpath(__DIR__ . '/../install.php');
if ($maintenance_mode) {
echo file_get_contents(__DIR__ . '/../public/maintenance.html');
die();
@@ -92,8 +94,7 @@
session_start();
gettext_init();
-
-sql_connect($config['host'], $config['user'], $config['pw'], $config['db']);
+sql_connect($DB_HOST, $DB_USER, $DB_PASSWORD,$DB_NAME);
load_auth();
diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php
index c3366650b..01bf1751b 100644
--- a/includes/helper/internationalization_helper.php
+++ b/includes/helper/internationalization_helper.php
@@ -75,5 +75,4 @@ function make_langselect() {
$items[] = toolbar_item_link(htmlspecialchars($URL) . $locale, '', ' ' . $name);
return $items;
}
-
-?>
\ No newline at end of file
+?>
diff --git a/includes/model/Settings_model.php b/includes/model/Settings_model.php
index a42442d92..3406380f6 100644
--- a/includes/model/Settings_model.php
+++ b/includes/model/Settings_model.php
@@ -43,4 +43,12 @@ function Settings() {
return sql_select("SELECT * FROM `Settings`");
}
+function update_table_migrated($value) {
+ return sql_query("UPDATE `Settings` SET `table_migrated`='" . sql_escape($value) . "'");
+}
+
+function insert_table_migrated($value) {
+ return sql_query("INSERT INTO `Settings` SET `table_migrated`='" . sql_escape($value) . "'");
+}
+
?>
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index c8ce8a0bb..7ad185488 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -552,4 +552,11 @@ function user_by_id($id) {
return sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
}
+function update_nick($username, $uid) {
+ return sql_query("UPDATE `User` SET `Nick`='" . sql_escape($username) . "' WHERE `UID`='" . sql_escape($uid) . "'");
+}
+
+function update_mail($email, $uid) {
+ return sql_query("UPDATE `User` SET `email`='" . sql_escape($email) . "' WHERE `UID`='" . sql_escape($uid) . "'");
+}
?>
diff --git a/includes/model/import_model.php b/includes/model/import_model.php
new file mode 100644
index 000000000..620249fc4
--- /dev/null
+++ b/includes/model/import_model.php
@@ -0,0 +1,28 @@
+
diff --git a/includes/sys_auth.php b/includes/sys_auth.php
index 12c21fdda..fb8abea87 100644
--- a/includes/sys_auth.php
+++ b/includes/sys_auth.php
@@ -67,4 +67,4 @@ function privileges_for_group($group_id) {
$privileges[] = $guest_priv['name'];
return $privileges;
}
-?>
\ No newline at end of file
+?>
diff --git a/includes/sys_menu.php b/includes/sys_menu.php
index 3bfa51856..74e4f7632 100644
--- a/includes/sys_menu.php
+++ b/includes/sys_menu.php
@@ -15,16 +15,21 @@ function page_link_to_absolute($page) {
*/
function header_toolbar() {
global $p, $privileges, $user, $enable_tshirt_size, $max_freeloadable_shifts;
-
+ $settings = array();
+ $no_migrated = "";
+ if (test_import()) {
+ $settings = Settings();
+ $no_migrated = $settings[0]['table_migrated'];
+ }
$toolbar_items = array();
if (isset($user))
$toolbar_items[] = toolbar_item_link(page_link_to('shifts') . '&action=next', 'time', User_shift_state_render($user));
- if (! isset($user) && in_array('register', $privileges))
+ if (! isset($user) && in_array('register', $privileges) && $no_migrated == 1)
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $p == 'register');
- if (in_array('login', $privileges))
+ if (in_array('login', $privileges) && $no_migrated == 1)
$toolbar_items[] = toolbar_item_link(page_link_to('login'), 'log-in', login_title(), $p == 'login');
if (isset($user) && in_array('user_messages', $privileges))
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 66b5064ef..cf7c4ec4d 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -487,4 +487,4 @@ function form_multiselect($name, $label, $values, $tag = "") {
$list .= '';
return $list;
}
-?>
\ No newline at end of file
+?>
diff --git a/install.php b/install.php
new file mode 100644
index 000000000..31957647b
--- /dev/null
+++ b/install.php
@@ -0,0 +1,102 @@
+ 1) {
+ $username = strip_request_item('username');
+ } else {
+ $ok = false;
+ $msg = error(sprintf(_("Your username is too short (min. 2 characters).")), true);
+ }
+
+ if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) {
+ if ($_REQUEST['password'] != $_REQUEST['password2']) {
+ $ok = false;
+ $msg = error(_("Your passwords don't match."), true);
+ }
+ } else {
+ $ok = false;
+ $msg = error(sprintf(_("Your password is too short (please use at least %s characters)."), MIN_PASSWORD_LENGTH), true);
+ }
+
+ if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) && preg_match("/^[a-z0-9._+-]{1,64}@(?:[a-z0-9-]{1,63}\.){1,125}[a-z]{2,63}$/", $_REQUEST['mail']) > 0) {
+ $mail = strip_request_item('mail');
+ if (! check_email($mail)) {
+ $ok = false;
+ $msg = error(_("E-mail address is not correct."), true);
+ }
+ } else {
+ $ok = false;
+ $msg = error(_("Please enter your correct e-mail (in lowercase)."), true);
+ }
+ }
+
+ if ($ok) {
+ $uid = 1;
+ if ($val) {
+ $no_migrated = 1;
+ insert_table_migrated($no_migrated);
+ update_nick($username, $uid);
+ update_mail($mail, $uid);
+ set_password($uid, $_REQUEST['password']);
+ success(_("Files imported successfully to database"));
+ success(_("Installation successful."));
+ redirect(page_link_to('login'));
+ }
+ else {
+ error(_("Installation Failed"));
+ redirect(page_link_to('install'));
+ }
+ }
+ return page_with_title(install_title(), array(
+ $msg,
+ div('well well-sm text-center', [
+ ('Welcome')
+ ]).div('row', array(
+ div('col-md-12', array(
+ form(array(
+ form_info('', _("Welcome to the famous five-minute Engelsystem installation process! Just fill in the information below and you’ll be on your way to volunteer management application for events with admin rights.")),
+ ))
+ ))
+ )).div('well well-sm text-center', [
+ _('Information Needed')
+ ]).div('row', array(
+ div('col-md-12', array(
+ form(array(
+ form_info('', _("Please provide the following information. Don’t worry, you can always change these settings later. All fields are compulsory")),
+ form_text('username', _("Enter Admin Username"), $username),
+ form_password('password', _("Enter New Password")),
+ form_password('password2', _("Confirm Password")),
+ form_email('mail', _("Enter E-Mail"), $mail),
+ form_submit('install', _("Install Engelsystem"))
+ ))
+ ))
+ ))
+ ));
+ }
+}
+?>
diff --git a/install_dependencies.sh b/install_dependencies.sh
new file mode 100755
index 000000000..12e5bbbb8
--- /dev/null
+++ b/install_dependencies.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+
+# Authors:
+# Sreeja Kamishetty
Translation