Skip to content

Commit

Permalink
Merge pull request #20 from Wutze/devel
Browse files Browse the repository at this point in the history
fix Request #19
  • Loading branch information
Wutze authored Jul 20, 2020
2 parents 934fd2a + f459cca commit 9825111
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 35 deletions.
10 changes: 5 additions & 5 deletions include/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

(stripos($_SERVER['PHP_SELF'], basename(__FILE__)) === false) or die('access denied?');

$host = '';
$port = '3306';
$db = '';
$user = '';
$pass = '';
$dbhost = '';
$dbport = '3306';
$dbname = '';
$dbuser = '';
$dbpass = '';
$dbtype = 'mysqli';
$dbdebug = FALSE;
$sessdebug = FALSE;
Expand Down
10 changes: 5 additions & 5 deletions include/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@

require_once(REAL_BASE_DIR."/include/config.php");
## User and Database Data
define('_DB_UNAME',$user);
define('_DB_PW',$pass);
define('_DB_DB',$db);
define('_DB_SERVER',$host);
define('_DB_UNAME',$dbuser);
define('_DB_PW',$dbpass);
define('_DB_DB',$dbname);
define('_DB_SERVER',$dbhost);
define('_DB_TYPE',$dbtype);
define('_DB_PORT',$port);
define('_DB_PORT',$dbport);
define('_DB_DEBUG',$dbdebug);
define('_SESSION_DEBUG',$sessdebug);

Expand Down
10 changes: 5 additions & 5 deletions installation/scripts/config.sample.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# MySQL credentials
HOST=''
PORT='3306'
USER=''
PASS=''
DB=''
DBHOST=''
DBPORT='3306'
DBUSER=''
DBPASS=''
DBNAME=''
4 changes: 2 additions & 2 deletions installation/scripts/connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fi


# We insert data in the log table
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "INSERT INTO log (log_id, user_id, log_trusted_ip, log_trusted_port, log_remote_ip, log_remote_port, log_start_time, log_end_time, log_received, log_send) VALUES(NULL, '$common_name','$trusted_ip', '$trusted_port','$ifconfig_pool_remote_ip', '$remote_port_1', now(),NULL, '$bytes_received', '$bytes_sent')"
mysql -h$DBHOST -P$DBPORT -u$DBUSER -p$DBPASS $DBNAME -e "INSERT INTO log (log_id, user_id, log_trusted_ip, log_trusted_port, log_remote_ip, log_remote_port, log_start_time, log_end_time, log_received, log_send) VALUES(NULL, '$common_name','$trusted_ip', '$trusted_port','$ifconfig_pool_remote_ip', '$remote_port_1', now(),NULL, '$bytes_received', '$bytes_sent')"

# We specify that the user is online
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE user SET user_online=1 WHERE user_id='$common_name'"
mysql -h$DBHOST -P$DBPORT -u$DBUSER -p$DBPASS $DBNAME -e "UPDATE user SET user_online=1 WHERE user_id='$common_name'"
6 changes: 4 additions & 2 deletions installation/scripts/disconnect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ trusted_ip=$(echap "$trusted_ip")
trusted_port=$(echap "$trusted_port")

# We specify the user is offline
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE user SET user_online=0 WHERE user_id='$common_name'"
mysql -h$DBHOST -P$DBPORT -u$DBUSER -p$DBPASS $DBNAME -e "UPDATE user SET user_online=0 WHERE user_id='$common_name'"

# We insert the deconnection datetime
mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -e "UPDATE log SET log_end_time=now(), log_received='$bytes_received', log_send='$bytes_sent' WHERE log_trusted_ip='$trusted_ip' AND log_trusted_port='$trusted_port' AND user_id='$common_name' AND log_end_time IS NULL"
mysql -h$DBHOST -P$DBPORT -u$DBUSER -p$DBPASS $DBNAME -e "UPDATE log SET log_end_time=now(), log_received='$bytes_received', log_send='$bytes_sent' WHERE log_trusted_ip='$trusted_ip' AND log_trusted_port='$trusted_port' AND user_id='$common_name' AND log_end_time IS NULL"

echo $(date '+%a %b %d %H:%M:%S %Y')" [ovpn] disconnect $common_name: [QUIT]"
11 changes: 7 additions & 4 deletions installation/scripts/login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
username=$(echap "$username")
password=$(echap "$password")

echo $(date '+%a %b %d %H:%M:%S %Y')" [ovpn] Start Login Process for: $username: [INFO]"

# Authentication
user_pass=$(mysql -h$HOST -P$PORT -u$USER -p$PASS $DB -sN -e "SELECT user_pass FROM user WHERE user_id = '$username' AND user_enable=1 AND (TO_DAYS(now()) >= TO_DAYS(user_start_date) OR user_start_date IS NULL) AND (TO_DAYS(now()) <= TO_DAYS(user_end_date) OR user_end_date IS NULL)")
user_pass=$(mysql -h$DBHOST -P$DBPORT -u$DBUSER -p$DBPASS $DBNAME -sN -e "SELECT user_pass FROM user WHERE user_id = '$username' AND user_enable=1 AND (TO_DAYS(now()) >= TO_DAYS(user_start_date) OR user_start_date IS NULL) AND (TO_DAYS(now()) <= TO_DAYS(user_end_date) OR user_end_date IS NULL)")

# Check the user
# write log entry
if [ "$user_pass" == '' ]; then
echo "$username: bad account."
echo $(date '+%a %b %d %H:%M:%S %Y')" [ovpn] $username: authentication: [ERROR] bad account"
exit 1
fi

result=$(php -r "if(password_verify('$password', '$user_pass') == true) { echo 'ok'; } else { echo 'ko'; }")

if [ "$result" == "ok" ]; then
echo "$username: authentication ok."
echo $(date '+%a %b %d %H:%M:%S %Y')" [ovpn] $username: authentication: [OK]"
exit 0
else
echo "$username: authentication failed."
echo $(date '+%a %b %d %H:%M:%S %Y')" [ovpn] $username: authentication: [ERROR] failed"
exit 1
fi
39 changes: 28 additions & 11 deletions lang/de_DE
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,32 @@ SETFIN02="Um die Installation zu beenden, konfiguriere bitte Deinen Webserver (A
SETFIN03="Du musst den Server neu starten, da OpenVPN sonst nicht korrekt funktioniert!"
SETFIN04="Fragen, Antworten, Wünsche, Fehler bitte da mitteilen: https://github.com/Wutze/OpenVPN-WebAdmin/issues"












### Update Variablen
UPSEL00="Update Informationen"
UPSEL01="Update von Version 0.8 zu 1.1.0"
UPSEL02="Generelles Update System 1.1.x"
UPSEL03=""
UPSEL04="Fragen zur Installation"

UPVERSIO="Installierte Version "
UPDBHOST="Datenbankhost * "
UPDBUSER="Datenbank Benutzer * "
UPDBPASS="Datenbankpasswort * "
UPDBNAME="Datenbank Name * "
UPWEBDIR="Webverzeichnis * "
UPWEBROO="Webroot * "
UPPATHOW="Eigentümer "
UPMASHID="Installiert auf Machine-ID "
INSTALLD="Installiert am "
UPDATAOK="* Angaben erforderlich!
Alle Angaben korrekt?"

UPDATEINF01="Bitte mache VOR Beginn dieses Updates von Deinem Server ein Backup. Trotz aller Tests die ich durchführen kann,
kann ich keine Fehler auf Deinem Server sehen um darauf entsprechend reagieren.
Mit diesem Update werden jedoch einige Funktionalitäten eingeführt, die ein späteres Backup möglich machen.
Weiter machen?
"
UPDATEINF02="Kontolle der Variablen"
29 changes: 29 additions & 0 deletions lang/en_EN
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,35 @@ SETFIN03="You must restart the server, otherwise OpenVPN will not work correctly
SETFIN04="Questions, answers, wishes, mistakes please communicate there: https://github.com/Wutze/OpenVPN-WebAdmin/issues"


### Update variables
UPSEL00="Update Information"
UPSEL01="Update from Version 0.8 to 1.1.0"
UPSEL02="General Update System 1.1.x"
UPSEL03=""
UPSEL04="Installation Questions"

UPVERSIO="Installed Version "
UPDBHOST="Database host * "
UPDBUSER="Database user * "
UPDBPASS="Database password * "
UPDBNAME="Database Name * "
UPWEBDIR="Web directory * "
UPWEBROO="Webroot * "
UPPATHOW="Owner "
UPMASHID="Installed on Machine ID "
INSTALLD="Installed on "
UPDATAOK="* Information required!
All data correct?"

UPDATEINF01="Please make a backup of your server BEFORE starting this update. Despite all the tests I can do,
I can't see any errors on your server to react accordingly.
However, this update introduces some functionality that makes a later backup possible.
Continue?
"
UPDATEINF02="Control of variables"



2 changes: 1 addition & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ write_config(){
main(){

# select language german or english
sel_lang
sel_lang
# main logo
intro
if_updatefile_exist
Expand Down

0 comments on commit 9825111

Please sign in to comment.