Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Change config file name #160

Open
wants to merge 212 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
212 commits
Select commit Hold shift + click to select a range
2752f1d
Update install.sh
arvage Apr 27, 2020
07f9a6c
Update README.md
arvage Apr 27, 2020
f95f670
Update README.md
arvage Apr 27, 2020
f74fbca
Update server.conf
arvage Apr 27, 2020
ada07c9
Update install.sh
arvage Apr 27, 2020
d22b09f
Update install.sh
arvage Apr 27, 2020
ef3f6bc
Update install.sh
arvage Apr 27, 2020
69b0985
Update install.sh
arvage Apr 27, 2020
c207baa
Update install.sh
arvage Apr 27, 2020
115a352
Update install.sh
arvage Apr 27, 2020
ddff862
Update README.md
arvage Apr 27, 2020
c35d9a6
Update README.md
arvage Apr 27, 2020
fac2d7d
Delete icon.png
arvage Apr 27, 2020
c1b119b
Add files via upload
arvage Apr 27, 2020
868bf13
Update install.sh
arvage Apr 27, 2020
10e244a
Update README.md
arvage Apr 27, 2020
6954c98
Update install.sh
arvage Apr 28, 2020
b85b6c6
Update install.sh
arvage Apr 28, 2020
c4552dd
Update index.php
arvage Apr 28, 2020
074b868
Update configuration.php
arvage Apr 28, 2020
d6514ab
Update index.php
arvage Apr 28, 2020
d821641
Update index.php
arvage Apr 28, 2020
c3bad15
Update install.sh
arvage May 1, 2020
47e526a
Update install.sh
arvage May 1, 2020
6e5ba47
Create .htaccess
arvage May 1, 2020
8056284
Update install.sh
arvage May 1, 2020
27dfb33
Update install.sh
arvage May 1, 2020
00a8f9f
Update install.sh
arvage May 1, 2020
145f047
Fixed client conf download
arvage May 1, 2020
d3ee3a7
Update README.md
arvage May 1, 2020
00e29a7
Visual touchups
arvage May 1, 2020
702d47c
Merge branch 'master' of https://github.com/arvage/OpenVPN-Admin
arvage May 1, 2020
b025f20
visual touchups
arvage May 1, 2020
5e88c7b
added git as prerequisite
arvage May 1, 2020
acf5dcc
fixed configuration file name on save
arvage May 1, 2020
d386543
Update install.sh
arvage May 1, 2020
e15d057
Update install.sh
arvage May 1, 2020
0cbe2be
Update install.sh
arvage May 1, 2020
3620a03
fixed error when no sql user provided
arvage May 1, 2020
fb0c554
Update README.md
arvage May 1, 2020
5d719ea
Update install.sh
arvage May 1, 2020
4fc47e4
Update README.md
arvage May 1, 2020
4d7dca5
Update install.sh
arvage May 1, 2020
b3b6968
added instruction button
arvage May 1, 2020
2ed02ff
manual
arvage May 1, 2020
4d38c24
download instructions
arvage May 1, 2020
2e91230
download instructions
arvage May 1, 2020
67ee746
get instructions
arvage May 1, 2020
8841a5e
instruction ger
arvage May 2, 2020
c76c04b
Fully automated install
arvage May 2, 2020
23e0763
removed unnecessary package install
arvage May 2, 2020
831198e
fix easy-rsa
arvage May 2, 2020
f6064e8
Update README.md
arvage May 2, 2020
2db974b
online install created
arvage May 2, 2020
975c65d
online install
arvage May 2, 2020
66de7fb
automated install
arvage May 2, 2020
04608ce
Updating client-conf folder web security
arvage May 3, 2020
7a121d0
Providing auto-generated information when finished
arvage May 3, 2020
3e730fe
fixed hostname
arvage May 3, 2020
65b36ec
fixed error on auto install
arvage May 3, 2020
005350f
fixed final messages
arvage May 3, 2020
d431307
rearranged the script
arvage May 3, 2020
6f06ac0
Update README.md
arvage May 3, 2020
e36329e
added auto admin install
arvage May 3, 2020
9560e01
Update README.md
arvage May 3, 2020
3744d9e
fixed an error
arvage May 3, 2020
74bc507
fixed mariadb error
arvage May 3, 2020
6e374f7
fixed prerequisite checkups
arvage May 3, 2020
0e87d08
error fix
arvage May 3, 2020
6f41b85
script touchups
arvage May 3, 2020
4f43760
add user auto start date to date
arvage May 4, 2020
7a69e86
static timezone added
arvage May 4, 2020
526fd0e
static timezone added
arvage May 4, 2020
92c64af
fixed sql user or pass error
arvage May 4, 2020
c5e17da
added download conf to admin page
arvage May 4, 2020
b2302d9
added configurations table
arvage May 4, 2020
3423248
update
arvage May 4, 2020
e340dad
update
arvage May 4, 2020
10110ef
Update README.md
arvage May 4, 2020
dcbf6d2
Update README.md
arvage May 4, 2020
6c0a59c
Update README.md
arvage May 4, 2020
c51fdbd
added config download button to admin page
arvage May 4, 2020
ccd09cc
updated unistall
arvage May 4, 2020
dc93d3c
update
arvage May 4, 2020
d33ba61
auto first time admin install
arvage May 4, 2020
5eb6b86
updated public ip and hotname
arvage May 4, 2020
b75916f
update install
arvage May 4, 2020
e0b36ea
updated install
arvage May 5, 2020
80c75a9
updated install script
arvage May 5, 2020
946a6e9
updated install script
arvage May 5, 2020
a1bf476
Update install.sh
arvage May 5, 2020
7a53df2
updated install script
arvage May 5, 2020
9a8b442
timeout for hostname input for automated install
arvage May 5, 2020
6c330d2
updated install script
arvage May 5, 2020
f03b705
update
arvage May 5, 2020
3860451
update
arvage May 5, 2020
a32f9fc
update
arvage May 5, 2020
3911af0
added mysql timezone to install script
arvage May 5, 2020
94e51f4
fixed MySQL timezone.
arvage May 5, 2020
463776c
fix
arvage May 5, 2020
bab6166
fix
arvage May 5, 2020
8891733
update
arvage May 5, 2020
9fb12ed
fix
arvage May 5, 2020
7b1d023
fix
arvage May 5, 2020
9e2af72
fix
arvage May 5, 2020
9f42e08
added npm update line
arvage May 5, 2020
fdf0368
update
arvage May 5, 2020
a0fcbe0
added ip_forward for ubuntu
arvage May 6, 2020
c6ae7be
welcome ubuntu full install
arvage May 6, 2020
474cff9
grammar typo fixed. fixed KB and MB
arvage May 6, 2020
07e34b3
removed 2 columns from logs table
arvage May 6, 2020
0d282d1
removed decimals from bytes send and received
arvage May 6, 2020
0b814e6
added coloring to logs based on MB KB
arvage May 6, 2020
17a04be
coloring logs
arvage May 6, 2020
11f09e7
logs coloring
arvage May 6, 2020
4ebbede
logs coloring
arvage May 6, 2020
5941e18
logs coloring
arvage May 7, 2020
ea68f67
log table text align
arvage May 7, 2020
0104ea3
update
arvage May 7, 2020
3147dc7
added download filename selection to install script
arvage May 7, 2020
8d42a4e
added config file manual setup in install script
arvage May 7, 2020
00a1b07
fixed error
arvage May 7, 2020
276200d
download filename selection on install script
arvage May 7, 2020
d72952e
fixed error on changing file name
arvage May 7, 2020
7b870aa
updated install script user outputs
arvage May 7, 2020
067966f
updated user outputs
arvage May 7, 2020
ec5440c
fixed file save name
arvage May 7, 2020
e81debe
updated user comments
arvage May 7, 2020
5527166
fixed download file extension
arvage May 7, 2020
6825b7e
quick fix
arvage May 7, 2020
599de1b
force iptables save rules on Ubuntu
arvage Jul 15, 2020
0003e30
Added MAC instructions
arvage Oct 21, 2020
2911675
MAC instructions
arvage Oct 21, 2020
d44698c
Update index.php
arvage Oct 21, 2020
6d6a0b9
Update configuration.php
arvage Oct 21, 2020
986827d
Update configuration.php
arvage Oct 21, 2020
7756f73
Fixed filename
arvage Apr 12, 2021
db6d63b
Delete Download and install the OpenVPN GUI.pdf
arvage Apr 12, 2021
81170ee
Added Debian Support
arvage Jul 17, 2021
0ad1185
Update install.sh
arvage Jul 17, 2021
8071548
Update install.sh
arvage Jul 21, 2021
0a03546
Update install.sh
arvage Jul 21, 2021
b48f4e5
minor touch
arvage Aug 30, 2021
a2bebbd
Added filename tab and configurations
arvage Sep 2, 2021
ee7e4a3
now saving ovpn file based on filename in configs
arvage Sep 2, 2021
2885994
Create filename
arvage Sep 2, 2021
4bbbe09
Update grids.php
arvage Sep 2, 2021
0e0b86c
Update install.sh
arvage Sep 2, 2021
7722f71
touchups :)
arvage Sep 2, 2021
38fa71d
Update online-install.sh
arvage Sep 2, 2021
a0a025b
fixed a missing quotation
arvage Sep 15, 2021
5bad8e4
Fixed IP forward issue after reboots
arvage Oct 8, 2021
d279b0c
Update install.sh
arvage Oct 14, 2021
4a8d153
fixed .ovpn file save
arvage Oct 14, 2021
5bb52b3
Update online-install.sh
arvage Oct 14, 2021
fa77b96
Update online-install.sh
arvage Oct 14, 2021
28ac14b
Update online-install.sh
arvage Oct 14, 2021
9ace200
Update online-install.sh
arvage Oct 14, 2021
b6f8403
Update README.md
arvage Oct 14, 2021
06dfa13
Update online-install.sh
arvage Oct 14, 2021
ca21625
Update online-install.sh
arvage Oct 14, 2021
219d718
Update filename
arvage Oct 14, 2021
603713f
fixed MySQL root password reset
arvage Oct 14, 2021
bad7a71
Update online-install.sh
arvage Oct 14, 2021
e96d433
Update install.sh
arvage Oct 14, 2021
6ed245a
Update install.sh
arvage Oct 14, 2021
22ff51a
Update README.md
arvage Oct 14, 2021
cdba39a
Update README.md
arvage Oct 14, 2021
342a1b5
Update install.sh
arvage Oct 14, 2021
241b82f
Update install.sh
arvage Oct 14, 2021
6c56b8b
Update install.sh
arvage Oct 14, 2021
7779a3d
Update README.md
arvage Oct 14, 2021
59e714b
Update install.sh
arvage Oct 14, 2021
4b5f133
Update install.sh
arvage Oct 14, 2021
4660d63
Update install.sh
arvage Oct 14, 2021
fdbe29f
Update install.sh
arvage Oct 15, 2021
869c109
Update install.sh
arvage Oct 15, 2021
9aab409
Update online-install.sh
arvage Oct 15, 2021
42e3162
Update install.sh
arvage Oct 15, 2021
45aee9a
Update install.sh
arvage Oct 15, 2021
1c716ef
Update online-install.sh
arvage Oct 15, 2021
b19d788
Update install.sh
arvage Oct 15, 2021
5ea1682
Update install.sh
arvage Oct 15, 2021
d6606ab
Update README.md
arvage Nov 24, 2021
c0a2212
Update README.md
arvage Nov 24, 2021
7a130e1
getting ready for ubuntu 22
Aug 24, 2022
2dfacd0
getting ready for ubuntu 22
Aug 24, 2022
78cfed6
adding php7.4 to ubuntu 22
Aug 24, 2022
dcb0327
SSL CERT expiration is 100 years now
Aug 24, 2022
c1a4eca
fixed a tiny error
Aug 24, 2022
db686a0
fixed an error
Aug 24, 2022
6b034d1
tiny fix
Aug 24, 2022
5d9fad7
debugging
Aug 24, 2022
c31d5a4
tiny fix
Aug 24, 2022
76dbee3
tiny fix again!
Aug 24, 2022
614c996
fix!
Aug 24, 2022
2c827c2
fix2.0
Aug 24, 2022
57d7d49
unattended install
Aug 24, 2022
f3be3ac
unattended install fix
Aug 24, 2022
796e03b
last fix!
Aug 24, 2022
470ce78
last fix?
Aug 24, 2022
10e25a7
corrected typo
Aug 24, 2022
794db2b
corrected typo
Aug 24, 2022
4c474f7
fixed SQL query
Aug 24, 2022
4cbe55f
added some art :)
Aug 24, 2022
06347be
Amiga!?
Aug 24, 2022
0036a49
new OpenSSL compatibility
arvage Nov 15, 2022
8b582f6
Update install.sh
arvage Nov 18, 2022
8d7f356
updated version
arvage Mar 22, 2023
b683575
FD0 removal!
arvage Mar 27, 2023
810ad4e
Added RDP on Mac
arvage Mar 27, 2023
748476f
removed FD0
arvage Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
88 changes: 25 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,53 @@
# OpenVPN Admin
## Raspberry Pi OpenVPN Admin using LAMP

## Summary
Administrate its OpenVPN with a web interface (logs visualisations, users managing...) and a SQL database.

![Previsualisation configuration](https://lutim.cpy.re/fUq2rxqz)
![Previsualisation administration](https://lutim.cpy.re/wwYMkHcM)
Administer OpenVPN Server with a web interface (Users Management, Logs, Visualizations)


## Prerequisite

* GNU/Linux with Bash and root access
* Fresh install of OpenVPN
* Web server (NGinx, Apache...)
* MySQL
* PHP >= 5.5 with modules:
* zip
* pdo_mysql
* bower
* unzip
* wget
* sed
* curl

### Debian 8 Jessie

````
# apt-get install openvpn apache2 php5-mysql mysql-server php5 nodejs unzip git wget sed npm curl
# npm install -g bower
# ln -s /usr/bin/nodejs /usr/bin/node
````

### Debian 9 Stretch

In order to install `npm`, [stretch-backports need to be added to your sources.list](https://backports.debian.org/Instructions/#index2h2).

````
# apt-get install -t stretch-backports npm nodejs
# apt-get install openvpn apache2 php-mysql mysql-server php-zip php unzip git wget sed curl
# npm install -g bower
````

### CentOS 7

````
# yum install epel-release
# yum install openvpn httpd php-mysql mariadb-server php nodejs unzip git wget sed npm
# npm install -g bower
# systemctl enable mariadb
# systemctl start mariadb
````

### Other distribution... (PR welcome)
* Raspbian or Ubuntu 20 with Bash access or remote SSH
* Ubuntu 21.x.x is not supprted yet

## Tests
## Installation

Only tested on Debian Jessie. Feel free to open issues.
* Method 1 (Automatic):

wget -O - https://raw.githubusercontent.com/arvage/OpenVPN-Admin/master/online-install.sh | bash

* Method 2 (Manual):

## Installation
sudo apt update
sudo apt install -y git
cd ~
git clone https://github.com/arvage/OpenVPN-Admin openvpn-admin
cd openvpn-admin
sudo ./install.sh /var/www www-data www-data

* Setup OpenVPN and the web application:
* Once the installation is finished browse to `http://your_hostname_or_ip/index.php?installation` to create your admin user.

$ cd ~/my_coding_workspace
$ git clone https://github.com/Chocobozzz/OpenVPN-Admin openvpn-admin
$ cd openvpn-admin
# ./install.sh /var/www www-data www-data
## Tests

* 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`
* Rasbian: Only tested on Raspberry Pi 3 with Raspbian Buster (No GUI).
* Ubuntu 20.04 LTS: Tested successfully

## Usage

* Start OpenVPN on the server (for example `systemctl start openvpn@server`)
* Connect to the web application as an admin
* Create an user
* Create a user
* User get the configurations files via the web application (and put them in */etc/openvpn*)
* Users on GNU/Linux systems, run `chmod +x /etc/openvpn/update-resolv.sh` as root
* User run OpenVPN (for example `systemctl start openvpn@client`)

## Update

$ git pull origin master
# ./update.sh /var/www
git pull origin master
./update.sh /var/www

## Desinstall
## Uninstall
It will remove all installed components (OpenVPN keys and configurations, the web application, iptables rules...).

# ./desinstall.sh /var/www
sudo ./uninstall.sh /var/www

## Use of

Expand Down
Binary file modified css/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions include/grids.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@

do {
// Better in Kb or Mb
$received = ($data['log_received'] > 1000000) ? $data['log_received']/1000000 . " Mo" : $data['log_received']/1000 . " Ko";
$sent = ($data['log_send'] > 1000000) ? $data['log_send']/1000000 . " Mo" : $data['log_send']/1000 . " Ko";
$received = ($data['log_received'] > 1000000) ? floor($data['log_received']/1000000) . " MB" : floor($data['log_received']/1000) . " KB";
$sent = ($data['log_send'] > 1000000) ? floor($data['log_send']/1000000) . " MB" : floor($data['log_send']/1000) . " KB";

// We add to the array the new line of logs
array_push($list, array(
Expand Down Expand Up @@ -136,7 +136,7 @@
$phone = "";
$online = 0;
$enable = 1;
$start = null;
$start = date("Y-m-d");
$end = null;

$req = $bdd->prepare('INSERT INTO user (user_id, user_pass, user_mail, user_phone, user_online, user_enable, user_start_date, user_end_date)
Expand Down
15 changes: 4 additions & 11 deletions include/html/form/configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="col-md-5 col-md-offset-3">

<form id="configuration_form" method="POST" class="panel panel-default">

Expand All @@ -17,17 +17,10 @@
<label for="configuration_pass">Password</label>
<input type="password" id="configuration_pass" name="configuration_pass" class="form-control" />
</div>
<input id="configuration_get" name="configuration_get" type="submit" value="ovpn Configuration File" class="btn btn-default" style="margin:10px;" />
<input id="windows_instruction_get" name="windows_instruction_get" type="submit" value="Windows Instructions" class="btn btn-default" style="margin:10px;" />
<input id="mac_instruction_get" name="mac_instruction_get" type="submit" value="MAC Instructions" class="btn btn-default" style="margin:10px;" />

<div class="form-group">
<label for="configuration_os">OS</label>
<select name="configuration_os" id="configuration_os" class="form-control">
<option value="gnu_linux">GNU/Linux</option>
<option value="osx_viscosity">OSX/Viscosity</option>
<option value="windows">Windows</option>
</select>
</div>

<input id="configuration_get" name="configuration_get" type="submit" value="Get configuration files" class="btn btn-default" />
</div>

</form>
Expand Down
23 changes: 18 additions & 5 deletions include/html/grids.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function getHistory($cfg_file, $accordion_id, $open_first_history_tab = false) {
<li><a data-toggle="tab" href="#menu1"><span class="glyphicon glyphicon-book" aria-hidden="true"></span> OpenVPN logs</a></li>
<li><a data-toggle="tab" href="#menu2"><span class="glyphicon glyphicon-king" aria-hidden="true"></span> Web Admins</a></li>
<li><a data-toggle="tab" href="#menu3"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Configs</a></li>
<li><a data-toggle="tab" href="#menu4"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> File name</a></li>
</ul>
<div class="tab-content">

Expand Down Expand Up @@ -119,10 +120,7 @@ function getHistory($cfg_file, $accordion_id, $open_first_history_tab = false) {
<!-- configs -->
<div class="block-grid row" id="config-cards">
<ul class="nav nav-tabs nav-tabs-justified">
<li class="active"><a data-toggle="tab" href="#menu-1-0"><span class="glyphicon glyphicon-heart" aria-hidden="true"></span> Linux</a></li>
<li><a data-toggle="tab" href="#menu-1-1"><span class="glyphicon glyphicon-th-large" aria-hidden="true"></span> Windows</a></li>
<li><a data-toggle="tab" href="#menu-1-2"><span class="glyphicon glyphicon-apple" aria-hidden="true"></span> OSX</a></li>

<li><a data-toggle="tab" href="#menu-1-1"><span class="glyphicon glyphicon-th-large" aria-hidden="true"></span> Windows, Linux and OSX</a></li>
<li id="save-config-btn" class="pull-right hidden"><a class="progress-bar-striped" href="javascript:;"><span class="glyphicon glyphicon-save" aria-hidden="true"></span></a></li>
</ul>
<div class="tab-content">
Expand All @@ -148,7 +146,22 @@ function getHistory($cfg_file, $accordion_id, $open_first_history_tab = false) {

</div>
</div>

<div id="menu4" class="tab-pane fade">
<!-- configs -->
<div class="block-grid row" id="config-cards">
<ul class="nav nav-tabs nav-tabs-justified">
<li><a data-toggle="tab" href="#menu-1-0"><span class="glyphicon glyphicon-heart" aria-hidden="true"></span> Ovpn Filename (without .ovpn extension)</a></li>
<li id="save-config-btn" class="pull-right hidden"><a class="progress-bar-striped" href="javascript:;"><span class="glyphicon glyphicon-save" aria-hidden="true"></span></a></li>
</ul>
<div class="tab-content">
<div id="menu-1-0" class="tab-pane fade in active">
<textarea class="form-control" data-config-file="<?= $cfg_file='client-conf/windows/filename' ?>" name="" id="" cols="30" rows="20"><?= file_get_contents($cfg_file) ?></textarea>
<?= getHistory($cfg_file, @++$accId) ?>
</div>
</div>
</div>
</div>

</div>

<script src="vendor/jquery/dist/jquery.min.js"></script>
Expand Down
108 changes: 61 additions & 47 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,79 @@
require(dirname(__FILE__) . '/include/functions.php');
require(dirname(__FILE__) . '/include/connect.php');

// first time install
if(($_SERVER[REQUEST_URI] != "/index.php?installation") && (isInstalled($bdd) == false)) {
header("Location: index.php?installation");
exit(-1);
}

// Disconnecting ?
if(isset($_GET['logout'])){
session_destroy();
header("Location: .");
exit(-1);
}

// Get the configuration files ?
if(isset($_POST['configuration_get'], $_POST['configuration_username'], $_POST['configuration_pass'], $_POST['configuration_os'])
&& !empty($_POST['configuration_pass'])) {
// Read ovpn file contents
$ovpn_filename= file_get_contents("./client-conf/windows/filename");

// Get the Windows instruction file
if(isset($_POST['windows_instruction_get'])) {
$download_file_name1 = "Download and install the OpenVPN GUI (Windows).pdf";
$file_folder1 = "windows";
$file_full_path1 = './client-conf/' . $file_folder1 . '/' . $download_file_name1;
header("Content-type: application/pdf");
header("Content-disposition: attachment; filename=$download_file_name1");
header("Pragma: no-cache");
header("Expires: 0");
readfile($file_full_path1);
exit;
}

// Get the MAC instruction file
if(isset($_POST['mac_instruction_get'])) {

$download_file_name2 = "Download and install the OpenVPN GUI (MAC).pdf";
$file_folder2 = "osx-viscosity";
$file_full_path2 = './client-conf/' . $file_folder2 . '/' . $download_file_name2;
header("Content-type: application/pdf");
header("Content-disposition: attachment; filename=$download_file_name2");
header("Pragma: no-cache");
header("Expires: 0");
readfile($file_full_path2);
exit;
}

// Get configuration file from admin page
if(isset($_GET['admin_configuration_get']) && !empty($_SESSION['admin_id']) ) {
$file_name = "client.ovpn";
$file_folder = "windows";
$file_full_path = './client-conf/' . $file_folder . '/' . $file_name;
header("Content-type: application/ovpn");
header("Content-disposition: attachment; filename=$ovpn_filename.ovpn");
header("Pragma: no-cache");
header("Expires: 0");
readfile($file_full_path);
exit;
}

// Get the configuration files from configuration page
if(isset($_POST['configuration_get'], $_POST['configuration_username'], $_POST['configuration_pass']) && !empty($_POST['configuration_pass'])) {
$req = $bdd->prepare('SELECT * FROM user WHERE user_id = ?');
$req->execute(array($_POST['configuration_username']));
$data = $req->fetch();

// Error ?
if($data && passEqual($_POST['configuration_pass'], $data['user_pass'])) {
// Thanks http://stackoverflow.com/questions/4914750/how-to-zip-a-whole-folder-using-php
if($_POST['configuration_os'] == "gnu_linux") {
$conf_dir = 'gnu-linux';
} elseif($_POST['configuration_os'] == "osx_viscosity") {
$conf_dir = 'osx-viscosity';
} else {
$conf_dir = 'windows';
}
$rootPath = realpath("./client-conf/$conf_dir");

// Initialize archive object ;;;; why doing this every time the user logs in, when the cert is static?
$archive_base_name = "openvpn-$conf_dir";
$archive_name = "$archive_base_name.zip";
$archive_path = "./client-conf/$archive_name";
$zip = new ZipArchive();
$zip->open($archive_path, ZipArchive::CREATE | ZipArchive::OVERWRITE);

$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $name => $file) {
// Skip directories (they would be added automatically)
if (!$file->isDir()) {
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);

// Add current file to archive
$zip->addFile($filePath, "$archive_base_name/$relativePath");
}
}

// Zip archive will be created only after closing object
$zip->close();

//then send the headers to foce download the zip file
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$archive_name");
$file_name = "client.ovpn";
$file_folder = "windows";
$file_full_path = './client-conf/' . $file_folder . '/' . $file_name;
header("Content-type: application/ovpn");
header("Content-disposition: attachment; filename=$ovpn_filename.ovpn");
header("Pragma: no-cache");
header("Expires: 0");
readfile($archive_path);
readfile($file_full_path);
exit;
}
else {
$error = true;
Expand Down Expand Up @@ -158,11 +172,10 @@
header( "refresh:3;url=index.php?admin" );
}
// Print the installation form
else {
else {
require(dirname(__FILE__) . '/include/html/menu.php');
require(dirname(__FILE__) . '/include/html/form/installation.php');
}

exit(-1);
}

Expand Down Expand Up @@ -196,6 +209,7 @@
<div class="col-md-6">
<a class="navbar-text navbar-right" href="index.php?logout" title="Logout"><button class="btn btn-danger">Logout <span class="glyphicon glyphicon-off" aria-hidden="true"></span></button></a>
<a class="navbar-text navbar-right" href="index.php" title="Configuration"><button class="btn btn-default">Configurations</button></a>
<a class="navbar-text navbar-right" href="index.php?admin_configuration_get" title="Get Config File"><button class="btn btn-default">Get Config File</button></a>
</p>
</div>
</div>
Expand All @@ -204,7 +218,7 @@
<?php
require(dirname(__FILE__) . '/include/html/grids.php');
}
?>
?>
<div id="message-stage">
<!-- used to display application messages (failures / status-notes) to the user -->
</div>
Expand Down
Loading