diff --git a/.bowerrc b/.bowerrc
deleted file mode 100644
index 6866ac2..0000000
--- a/.bowerrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "directory": "vendor"
-}
diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..0e2e314
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,31 @@
+# Web-application parameters
+APP_PATH=/var/www/html/openvpn-admin
+
+# Database parameters
+DB_HOST=172.17.0.1
+DB_PORT=3306
+DB_NAME=openvpn-admin
+DB_USER=openvpn
+DB_PASS=openvpn_pass
+
+# OpenVPN settings
+VPN_ADDR=localhost
+VPN_PORT=1194
+VPN_PROTO=tcp
+VPN_GROUP=nogroup
+VPN_INIF=tun0
+VPN_OUTIF=eth0
+VPN_NET=10.8.0.0/24
+
+# OpenVPN key parameters
+EASYRSA_KEY_SIZE=2048
+EASYRSA_CA_EXPIRE=3650
+EASYRSA_CERT_EXPIRE=3650
+EASYRSA_REQ_COUNTRY="US"
+EASYRSA_REQ_PROVINCE="California"
+EASYRSA_REQ_CITY="San Francisco"
+EASYRSA_REQ_ORG="Copyleft Certificate Co"
+EASYRSA_REQ_OU="My Organizational Unit"
+EASYRSA_REQ_EMAIL=me@example.net
+EASYRSA_REQ_CN=ChangeMe
+EASYRSA_BATCH=true
diff --git a/.gitignore b/.gitignore
index b7d6fa6..0b13e98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,12 @@
-.phpintel
-vendor/
+/.phpintel
+/.env
+/.idea/
+/vendor/
+/node_modules/
+/composer.lock
+/package-lock.json
+/public/css/
+/public/fonts/
+/public/js/
+/public/img/
+/public/client-conf/
diff --git a/README.md b/README.md
index 437719b..f549aa1 100644
--- a/README.md
+++ b/README.md
@@ -16,12 +16,20 @@ Administrate its OpenVPN with a web interface (logs visualisations, users managi
* PHP >= 5.5 with modules:
* zip
* pdo_mysql
- * bower
+ * composer
+ * npm
* unzip
* wget
* sed
* curl
+### Debian Stretch
+
+````
+# apt-get install openvpn nginx composer php-fpm php-mysql mysql-server php nodejs unzip git wget sed curl
+# ln -s /usr/bin/nodejs /usr/bin/node
+````
+
### Debian Jessie
````
@@ -46,16 +54,29 @@ Administrate its OpenVPN with a web interface (logs visualisations, users managi
Only tested on Debian Jessie. Feel free to open issues.
-## Installation
+## Installation (full)
* Setup OpenVPN and the web application:
$ cd ~/my_coding_workspace
$ git clone https://github.com/Chocobozzz/OpenVPN-Admin openvpn-admin
$ cd openvpn-admin
- # ./install.sh www_base_dir web_user web_group
+ $ npm install
+ $ composer install
+
+You can predefine all environment parameters, just copy example and put your changes in `.env`
+
+ # cp .env.example .env
+
+If you want to make ths full installation (with preparing of MySQL, Web-server and OpenVPN)
+
+ # ./install.sh www_base_dir web_user web_group
+
+If you want to configure only OpenVPN:
+
+ # ./install-openvpn.sh
- * Setup the web server (Apache, NGinx...) to serve the web application.
+ * Setup the web server (Apache, Nginx...) to serve the web application.
* Create the admin of the web application by visiting `http://your-installation/index.php?installation`
## Usage
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..f5ff126
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,16 @@
+{
+ "name": "chocobozzz/openvpn-admin",
+ "authors": [
+ {
+ "name": "Florian Bigard",
+ "email": "florian.bigard@gmail.com"
+ },
+ {
+ "name": "Paul Rock",
+ "email": "paul@drteam.rocks"
+ }
+ ],
+ "require": {
+ "vlucas/phpdotenv": "^2.4"
+ }
+}
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..f7c279e
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,62 @@
+var gulp = require('gulp');
+var copy = require('gulp-copy');
+var del = require('del');
+
+gulp.task('default', ['img', 'css', 'font', 'js']);
+
+gulp.task('clean:img', function () {
+ return del(['public/img']);
+});
+
+gulp.task('img', ['clean:img'], function () {
+ return gulp.src('resources/img/**/*')
+ .pipe(gulp.dest('public/img'));
+});
+
+gulp.task('clean:css', function () {
+ return del(['public/css']);
+});
+
+gulp.task('css', ['clean:css'], function () {
+ gulp.src(['resources/css/**/*.css'])
+ .pipe(gulp.dest('public/css'));
+
+ gulp
+ .src([
+ 'node_modules/bootstrap/dist/css/bootstrap.min.css',
+ 'node_modules/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css',
+ 'node_modules/bootstrap-table/dist/bootstrap-table.min.css',
+ 'node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css'
+ ])
+ .pipe(gulp.dest('public/css'));
+});
+
+gulp.task('clean:font', function() {
+ return del(['public/fonts']);
+});
+
+gulp.task('font', ['clean:font'], function() {
+ return gulp.src([
+ 'node_modules/bootstrap/dist/fonts/*',
+ ]).pipe(gulp.dest('public/fonts'));
+});
+
+gulp.task('clean:js', function () {
+ return del(['public/js']);
+});
+
+gulp.task('js', ['clean:js'], function () {
+ gulp.src(['resources/js/**/*.js'])
+ .pipe(gulp.dest('public/js'));
+
+ gulp
+ .src([
+ 'node_modules/jquery/dist/jquery.min.js',
+ 'node_modules/bootstrap/dist/js/bootstrap.min.js',
+ 'node_modules/bootstrap-table/dist/bootstrap-table.min.js',
+ 'node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.js',
+ 'node_modules/bootstrap-table/dist/extensions/editable/bootstrap-table-editable.min.js',
+ 'node_modules/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js'
+ ])
+ .pipe(gulp.dest('public/js'));
+});
diff --git a/include/config.php b/include/config.php
index 8d6a3de..f7f283c 100644
--- a/include/config.php
+++ b/include/config.php
@@ -1,7 +1,6 @@
+$host = getenv('DB_HOST');
+$port = getenv('DB_PORT');
+$db = getenv('DB_NAME');
+$user = getenv('DB_USER');
+$pass = getenv('DB_PASS');
diff --git a/include/connect.php b/include/connect.php
index 0add7e4..4bfd669 100644
--- a/include/connect.php
+++ b/include/connect.php
@@ -1,6 +1,5 @@
+$options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
+$bdd = new PDO("mysql:host=$host;port=$port;dbname=$db", $user, $pass, $options);
diff --git a/include/html/grids.php b/include/html/grids.php
index 5c4845f..fefcc3b 100644
--- a/include/html/grids.php
+++ b/include/html/grids.php
@@ -83,14 +83,3 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/bower.json b/package.json
similarity index 54%
rename from bower.json
rename to package.json
index fb22230..3475347 100644
--- a/bower.json
+++ b/package.json
@@ -2,21 +2,34 @@
"name": "openvpn-admin",
"version": "0.3.2",
"description": "Setup and administration of openvpn with a web interface",
- "dependencies": {
- "bootstrap": "^3.3.7",
- "bootstrap-table": "^1.11.0",
- "jquery": "^2.2.4",
- "x-editable": "^1.5.1",
- "bootstrap-datepicker": "^1.6.4"
+ "homepage": "https://github.com/EvilFreelancer/OpenVPN-Admin#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/EvilFreelancer/OpenVPN-Admin.git"
},
+ "authors": [
+ "Florian Bigard "
+ ],
"keywords": [
"openvpn",
"admin",
"setup"
],
- "authors": [
- "Florian Bigard "
- ],
"license": "GPLv3",
- "private": true
+ "bugs": {
+ "url": "https://github.com/EvilFreelancer/OpenVPN-Admin/issues"
+ },
+ "dependencies": {
+ "gulp": "^3.9.0",
+ "gulp-copy": "^1.1.0",
+ "del": "^2.0.0",
+ "bootstrap": "^3.3.7",
+ "bootstrap-table": "^1.11.0",
+ "jquery": "^2.2.4",
+ "x-editable": "^1.5.1",
+ "bootstrap-datepicker": "^1.6.4"
+ },
+ "scripts": {
+ "postinstall": "gulp"
+ }
}
diff --git a/include/grids.php b/public/grids.php
similarity index 96%
rename from include/grids.php
rename to public/grids.php
index 68a1138..2262410 100644
--- a/include/grids.php
+++ b/public/grids.php
@@ -4,9 +4,14 @@
if(!isset($_SESSION['admin_id']))
exit -1;
- require(dirname(__FILE__) . '/connect.php');
- require(dirname(__FILE__) . '/functions.php');
+ // Enable dotEnv support
+ require_once __DIR__ . '/../vendor/autoload.php';
+ (new Dotenv\Dotenv(__DIR__ . '/../'))->load();
+ session_start();
+
+ require(dirname(__FILE__) . '/../include/functions.php');
+ require(dirname(__FILE__) . '/../include/connect.php');
// ---------------- SELECT ----------------
if(isset($_GET['select'])){
diff --git a/index.php b/public/index.php
similarity index 77%
rename from index.php
rename to public/index.php
index 8266dd8..a36880e 100644
--- a/index.php
+++ b/public/index.php
@@ -1,8 +1,12 @@
load();
+
session_start();
- require(dirname(__FILE__) . '/include/functions.php');
- require(dirname(__FILE__) . '/include/connect.php');
+ require(dirname(__FILE__) . '/../include/functions.php');
+ require(dirname(__FILE__) . '/../include/connect.php');
// Disconnecting ?
if(isset($_GET['logout'])){
@@ -95,13 +99,13 @@
OpenVPN-Admin
-
-
-
-
-
+
+
+
+
+
-
+
exec($sql);
@@ -158,8 +162,8 @@
}
// Print the installation form
else {
- require(dirname(__FILE__) . '/include/html/menu.php');
- require(dirname(__FILE__) . '/include/html/form/installation.php');
+ require(dirname(__FILE__) . '/../include/html/menu.php');
+ require(dirname(__FILE__) . '/../include/html/form/installation.php');
}
exit(-1);
@@ -170,8 +174,8 @@
if(isset($error) && $error == true)
printError('Login error');
- require(dirname(__FILE__) . '/include/html/menu.php');
- require(dirname(__FILE__) . '/include/html/form/configuration.php');
+ require(dirname(__FILE__) . '/../include/html/menu.php');
+ require(dirname(__FILE__) . '/../include/html/form/configuration.php');
}
@@ -180,8 +184,8 @@
if(isset($error) && $error == true)
printError('Login error');
- require(dirname(__FILE__) . '/include/html/menu.php');
- require(dirname(__FILE__) . '/include/html/form/login.php');
+ require(dirname(__FILE__) . '/../include/html/menu.php');
+ require(dirname(__FILE__) . '/../include/html/form/login.php');
}
// --------------- GRIDS ---------------
@@ -200,9 +204,17 @@
-
+
+
+
+
+
+
+
+
+