Browse Source

small refactoring, check for non existed env file added

feature/refractoring
Paul Rock 7 years ago committed by Chocobozzz
parent
commit
d84f6803f7
  1. 0
      app/config.php
  2. 0
      app/connect.php
  3. 2
      app/functions.php
  4. 0
      app/html/form/configuration.php
  5. 0
      app/html/form/installation.php
  6. 0
      app/html/form/login.php
  7. 0
      app/html/grids.php
  8. 4
      app/html/menu.php
  9. 0
      app/resources/css/index.css
  10. 0
      app/resources/img/icon.png
  11. 0
      app/resources/js/grids.js
  12. 6
      gulpfile.js
  13. 269
      public/grids.php
  14. 297
      public/index.php

0
include/config.php → app/config.php

0
include/connect.php → app/connect.php

2
include/functions.php → app/functions.php

@ -41,5 +41,3 @@
function passEqual($pass, $hash) { function passEqual($pass, $hash) {
return password_verify($pass, $hash); return password_verify($pass, $hash);
} }
?>

0
include/html/form/configuration.php → app/html/form/configuration.php

0
include/html/form/installation.php → app/html/form/installation.php

0
include/html/form/login.php → app/html/form/login.php

0
include/html/grids.php → app/html/grids.php

4
include/html/menu.php → app/html/menu.php

@ -3,8 +3,8 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li <?php if(!isset($_GET['admin'])) echo 'class="active"'; ?>><a href="index.php">Configurations</a></li> <li <?php if(!isset($_GET['admin'])) echo 'class="active"'; ?>><a href="/">Configurations</a></li>
<li <?php if(isset($_GET['admin'])) echo 'class="active"'; ?>><a href="index.php?admin">Administrator</a></li> <li <?php if(isset($_GET['admin'])) echo 'class="active"'; ?>><a href="/?admin">Administrator</a></li>
</ul> </ul>
</div> </div>

0
resources/css/index.css → app/resources/css/index.css

0
resources/img/icon.png → app/resources/img/icon.png

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

0
resources/js/grids.js → app/resources/js/grids.js

6
gulpfile.js

@ -9,7 +9,7 @@ gulp.task('clean:img', function () {
}); });
gulp.task('img', ['clean:img'], function () { gulp.task('img', ['clean:img'], function () {
return gulp.src('resources/img/**/*') return gulp.src('app/resources/img/**/*')
.pipe(gulp.dest('public/img')); .pipe(gulp.dest('public/img'));
}); });
@ -18,7 +18,7 @@ gulp.task('clean:css', function () {
}); });
gulp.task('css', ['clean:css'], function () { gulp.task('css', ['clean:css'], function () {
gulp.src(['resources/css/**/*.css']) gulp.src(['app/resources/css/**/*.css'])
.pipe(gulp.dest('public/css')); .pipe(gulp.dest('public/css'));
gulp gulp
@ -46,7 +46,7 @@ gulp.task('clean:js', function () {
}); });
gulp.task('js', ['clean:js'], function () { gulp.task('js', ['clean:js'], function () {
gulp.src(['resources/js/**/*.js']) gulp.src(['app/resources/js/**/*.js'])
.pipe(gulp.dest('public/js')); .pipe(gulp.dest('public/js'));
gulp gulp

269
public/grids.php

@ -1,122 +1,112 @@
<?php <?php
session_start(); // Enable dotEnv support
require_once __DIR__ . '/../vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__ . '/../');
if (file_exists(__DIR__ . '/../.env')) $dotenv->load();
if(!isset($_SESSION['admin_id'])) session_start();
exit -1;
// Enable dotEnv support if (!isset($_SESSION['admin_id']))
require_once __DIR__ . '/../vendor/autoload.php'; exit - 1;
(new Dotenv\Dotenv(__DIR__ . '/../'))->load();
session_start(); require(dirname(__FILE__) . '/../app/functions.php');
require(dirname(__FILE__) . '/../app/connect.php');
require(dirname(__FILE__) . '/../include/functions.php'); // ---------------- SELECT ----------------
require(dirname(__FILE__) . '/../include/connect.php'); if (isset($_GET['select'])) {
// ---------------- SELECT ----------------
if(isset($_GET['select'])){
// Select the users // Select the users
if($_GET['select'] == "user"){ if ($_GET['select'] == "user") {
$req = $bdd->prepare('SELECT * FROM user'); $req = $bdd->prepare('SELECT * FROM user');
$req->execute(); $req->execute();
if($data = $req->fetch()) { if ($data = $req->fetch()) {
do { do {
$list[] = array("user_id" => $data['user_id'], $list[] = array("user_id" => $data['user_id'],
"user_pass" => $data['user_pass'], "user_pass" => $data['user_pass'],
"user_mail" => $data['user_mail'], "user_mail" => $data['user_mail'],
"user_phone" => $data['user_phone'], "user_phone" => $data['user_phone'],
"user_online" => $data['user_online'], "user_online" => $data['user_online'],
"user_enable" => $data['user_enable'], "user_enable" => $data['user_enable'],
"user_start_date" => $data['user_start_date'], "user_start_date" => $data['user_start_date'],
"user_end_date" => $data['user_end_date']); "user_end_date" => $data['user_end_date']);
} while($data = $req->fetch()); } while ($data = $req->fetch());
echo json_encode($list); echo json_encode($list);
} } // If it is an empty answer, we need to encore an empty json object
// If it is an empty answer, we need to encore an empty json object else {
else{ $list = array();
$list = array(); echo json_encode($list);
echo json_encode($list); }
} } // Select the logs
} else if ($_GET['select'] == "log" && isset($_GET['offset'], $_GET['limit'])) {
$offset = intval($_GET['offset']);
// Select the logs $limit = intval($_GET['limit']);
else if($_GET['select'] == "log" && isset($_GET['offset'], $_GET['limit'])){
$offset = intval($_GET['offset']); // Creation of the LIMIT for build different pages
$limit = intval($_GET['limit']); $page = "LIMIT $offset, $limit";
// Creation of the LIMIT for build different pages // Select the logs
$page = "LIMIT $offset, $limit"; $req_string = "SELECT *, (SELECT COUNT(*) FROM log) AS nb FROM log ORDER BY log_id DESC $page";
$req = $bdd->prepare($req_string);
// Select the logs $req->execute();
$req_string = "SELECT *, (SELECT COUNT(*) FROM log) AS nb FROM log ORDER BY log_id DESC $page";
$req = $bdd->prepare($req_string);
$req->execute();
$list = array();
$data = $req->fetch();
if($data) {
$nb = $data['nb'];
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";
// We add to the array the new line of logs
array_push($list, array(
"log_id" => $data['log_id'],
"user_id" => $data['user_id'],
"log_trusted_ip" => $data['log_trusted_ip'],
"log_trusted_port" => $data['log_trusted_port'],
"log_remote_ip" => $data['log_remote_ip'],
"log_remote_port" => $data['log_remote_port'],
"log_start_time" => $data['log_start_time'],
"log_end_time" => $data['log_end_time'],
"log_received" => $received,
"log_send" => $sent));
} while ($data = $req->fetch());
}
else {
$nb = 0;
}
// We finally print the result
$result = array('total' => intval($nb), 'rows' => $list);
echo json_encode($result);
}
// Select the admins
else if($_GET['select'] == "admin"){
$req = $bdd->prepare('SELECT * FROM admin');
$req->execute();
if($data = $req->fetch()) {
do{
$list[] = array(
"admin_id" => $data['admin_id'],
"admin_pass" => $data['admin_pass']
);
} while($data = $req->fetch());
echo json_encode($list);
}
else{
$list = array(); $list = array();
echo json_encode($list);
}
}
}
// ---------------- ADD USER ---------------- $data = $req->fetch();
else if(isset($_POST['add_user'], $_POST['user_id'], $_POST['user_pass'])){
if ($data) {
$nb = $data['nb'];
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";
// We add to the array the new line of logs
array_push($list, array(
"log_id" => $data['log_id'],
"user_id" => $data['user_id'],
"log_trusted_ip" => $data['log_trusted_ip'],
"log_trusted_port" => $data['log_trusted_port'],
"log_remote_ip" => $data['log_remote_ip'],
"log_remote_port" => $data['log_remote_port'],
"log_start_time" => $data['log_start_time'],
"log_end_time" => $data['log_end_time'],
"log_received" => $received,
"log_send" => $sent));
} while ($data = $req->fetch());
} else {
$nb = 0;
}
// We finally print the result
$result = array('total' => intval($nb), 'rows' => $list);
echo json_encode($result);
} // Select the admins
else if ($_GET['select'] == "admin") {
$req = $bdd->prepare('SELECT * FROM admin');
$req->execute();
if ($data = $req->fetch()) {
do {
$list[] = array(
"admin_id" => $data['admin_id'],
"admin_pass" => $data['admin_pass']
);
} while ($data = $req->fetch());
echo json_encode($list);
} else {
$list = array();
echo json_encode($list);
}
}
} // ---------------- ADD USER ----------------
else if (isset($_POST['add_user'], $_POST['user_id'], $_POST['user_pass'])) {
// Put some default values // Put some default values
$id = $_POST['user_id']; $id = $_POST['user_id'];
$pass = hashPass($_POST['user_pass']); $pass = hashPass($_POST['user_pass']);
@ -132,20 +122,18 @@
$req->execute(array($id, $pass, $mail, $phone, $online, $enable, $start, $end)); $req->execute(array($id, $pass, $mail, $phone, $online, $enable, $start, $end));
$res = array("user_id" => $id, $res = array("user_id" => $id,
"user_pass" => $pass, "user_pass" => $pass,
"user_mail" => $mail , "user_mail" => $mail,
"user_phone" => $phone, "user_phone" => $phone,
"user_online" => $online, "user_online" => $online,
"user_enable" => $enable, "user_enable" => $enable,
"user_start_date" => $start, "user_start_date" => $start,
"user_end_date" => $end "user_end_date" => $end
); );
echo json_encode($res); echo json_encode($res);
} } // ---------------- UPDATE USER ----------------
else if (isset($_POST['set_user'])) {
// ---------------- UPDATE USER ----------------
else if(isset($_POST['set_user'])){
$valid = array("user_id", "user_pass", "user_mail", "user_phone", "user_enable", "user_start_date", "user_end_date"); $valid = array("user_id", "user_pass", "user_mail", "user_phone", "user_enable", "user_start_date", "user_end_date");
$field = $_POST['name']; $field = $_POST['name'];
@ -153,36 +141,29 @@
$pk = $_POST['pk']; $pk = $_POST['pk'];
if (!isset($field) || !isset($pk) || !in_array($field, $valid)) { if (!isset($field) || !isset($pk) || !in_array($field, $valid)) {
return; return;
} }
if ($field === 'user_pass') { if ($field === 'user_pass') {
$value = hashPass($value); $value = hashPass($value);
} } else if (($field === 'user_start_date' || $field === 'user_end_date') && $value === '') {
else if (($field === 'user_start_date' || $field === 'user_end_date') && $value === '') { $value = NULL;
$value = NULL;
} }
// /!\ SQL injection: field was checked with in_array function // /!\ SQL injection: field was checked with in_array function
$req_string = 'UPDATE user SET ' . $field . ' = ? WHERE user_id = ?'; $req_string = 'UPDATE user SET ' . $field . ' = ? WHERE user_id = ?';
$req = $bdd->prepare($req_string); $req = $bdd->prepare($req_string);
$req->execute(array($value, $pk)); $req->execute(array($value, $pk));
} } // ---------------- REMOVE USER ----------------
else if (isset($_POST['del_user'], $_POST['del_user_id'])) {
// ---------------- REMOVE USER ----------------
else if(isset($_POST['del_user'], $_POST['del_user_id'])){
$req = $bdd->prepare('DELETE FROM user WHERE user_id = ?'); $req = $bdd->prepare('DELETE FROM user WHERE user_id = ?');
$req->execute(array($_POST['del_user_id'])); $req->execute(array($_POST['del_user_id']));
} } // ---------------- ADD ADMIN ----------------
else if (isset($_POST['add_admin'], $_POST['admin_id'], $_POST['admin_pass'])) {
// ---------------- ADD ADMIN ----------------
else if(isset($_POST['add_admin'], $_POST['admin_id'], $_POST['admin_pass'])){
$req = $bdd->prepare('INSERT INTO admin(admin_id, admin_pass) VALUES (?, ?)'); $req = $bdd->prepare('INSERT INTO admin(admin_id, admin_pass) VALUES (?, ?)');
$req->execute(array($_POST['admin_id'], hashPass($_POST['admin_pass']))); $req->execute(array($_POST['admin_id'], hashPass($_POST['admin_pass'])));
} } // ---------------- UPDATE ADMIN ----------------
else if (isset($_POST['set_admin'])) {
// ---------------- UPDATE ADMIN ----------------
else if(isset($_POST['set_admin'])){
$valid = array("admin_id", "admin_pass"); $valid = array("admin_id", "admin_pass");
$field = $_POST['name']; $field = $_POST['name'];
@ -190,22 +171,18 @@
$pk = $_POST['pk']; $pk = $_POST['pk'];
if (!isset($field) || !isset($pk) || !in_array($field, $valid)) { if (!isset($field) || !isset($pk) || !in_array($field, $valid)) {
return; return;
} }
if ($field === 'admin_pass') { if ($field === 'admin_pass') {
$value = hashPass($value); $value = hashPass($value);
} }
$req_string = 'UPDATE admin SET ' . $field . ' = ? WHERE admin_id = ?'; $req_string = 'UPDATE admin SET ' . $field . ' = ? WHERE admin_id = ?';
$req = $bdd->prepare($req_string); $req = $bdd->prepare($req_string);
$req->execute(array($value, $pk)); $req->execute(array($value, $pk));
} } // ---------------- REMOVE ADMIN ----------------
else if (isset($_POST['del_admin'], $_POST['del_admin_id'])) {
// ---------------- REMOVE ADMIN ----------------
else if(isset($_POST['del_admin'], $_POST['del_admin_id'])){
$req = $bdd->prepare('DELETE FROM admin WHERE admin_id = ?'); $req = $bdd->prepare('DELETE FROM admin WHERE admin_id = ?');
$req->execute(array($_POST['del_admin_id'])); $req->execute(array($_POST['del_admin_id']));
} }
?>

297
public/index.php

@ -1,152 +1,148 @@
<?php <?php
// Enable dotEnv support // Enable dotEnv support
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';
(new Dotenv\Dotenv(__DIR__ . '/../'))->load(); $dotenv = new Dotenv\Dotenv(__DIR__ . '/../');
if (file_exists(__DIR__ . '/../.env')) $dotenv->load();
session_start(); session_start();
require(dirname(__FILE__) . '/../include/functions.php'); require(dirname(__FILE__) . '/../app/functions.php');
require(dirname(__FILE__) . '/../include/connect.php'); require(dirname(__FILE__) . '/../app/connect.php');
// Disconnecting ? // Disconnecting ?
if(isset($_GET['logout'])){ if (isset($_GET['logout'])) {
session_destroy(); session_destroy();
header("Location: ."); header("Location: .");
exit(-1); exit(-1);
} }
// Get the configuration files ? // Get the configuration files ?
if(isset($_POST['configuration_get'], $_POST['configuration_username'], $_POST['configuration_pass'], $_POST['configuration_os']) if (isset($_POST['configuration_get'], $_POST['configuration_username'], $_POST['configuration_pass'], $_POST['configuration_os'])
&& !empty($_POST['configuration_pass'])) { && !empty($_POST['configuration_pass'])) {
$req = $bdd->prepare('SELECT * FROM user WHERE user_id = ?'); $req = $bdd->prepare('SELECT * FROM user WHERE user_id = ?');
$req->execute(array($_POST['configuration_username'])); $req->execute(array($_POST['configuration_username']));
$data = $req->fetch(); $data = $req->fetch();
// Error ? // Error ?
if($data && passEqual($_POST['configuration_pass'], $data['user_pass'])) { if ($data && passEqual($_POST['configuration_pass'], $data['user_pass'])) {
// Thanks http://stackoverflow.com/questions/4914750/how-to-zip-a-whole-folder-using-php // Thanks http://stackoverflow.com/questions/4914750/how-to-zip-a-whole-folder-using-php
if($_POST['configuration_os'] == "gnu_linux") { if ($_POST['configuration_os'] == "gnu_linux") {
$conf_dir = 'gnu-linux'; $conf_dir = 'gnu-linux';
} elseif($_POST['configuration_os'] == "osx_viscosity") { } elseif ($_POST['configuration_os'] == "osx_viscosity") {
$conf_dir = 'osx-viscosity'; $conf_dir = 'osx-viscosity';
} else { } else {
$conf_dir = 'windows'; $conf_dir = 'windows';
} }
$rootPath = realpath("./client-conf/$conf_dir"); $rootPath = realpath("./client-conf/$conf_dir");
// Initialize archive object // Initialize archive object
$archive_base_name = "openvpn-$conf_dir"; $archive_base_name = "openvpn-$conf_dir";
$archive_name = "$archive_base_name.zip"; $archive_name = "$archive_base_name.zip";
$archive_path = "./client-conf/$archive_name"; $archive_path = "./client-conf/$archive_name";
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip->open($archive_path, ZipArchive::CREATE | ZipArchive::OVERWRITE); $zip->open($archive_path, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = new RecursiveIteratorIterator( $files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath), new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY RecursiveIteratorIterator::LEAVES_ONLY
); );
foreach ($files as $name => $file) { foreach ($files as $name => $file) {
// Skip directories (they would be added automatically) // Skip directories (they would be added automatically)
if (!$file->isDir()) { if (!$file->isDir()) {
// Get real and relative path for current file // Get real and relative path for current file
$filePath = $file->getRealPath(); $filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1); $relativePath = substr($filePath, strlen($rootPath) + 1);
// Add current file to archive // Add current file to archive
$zip->addFile($filePath, "$archive_base_name/$relativePath"); $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 // Zip archive will be created only after closing object
header("Content-type: application/zip"); $zip->close();
header("Content-Disposition: attachment; filename=$archive_name");
header("Pragma: no-cache"); //then send the headers to foce download the zip file
header("Expires: 0"); header("Content-type: application/zip");
readfile($archive_path); header("Content-Disposition: attachment; filename=$archive_name");
} header("Pragma: no-cache");
else { header("Expires: 0");
$error = true; readfile($archive_path);
} else {
$error = true;
} }
} } // Admin login attempt ?
else if (isset($_POST['admin_login'], $_POST['admin_username'], $_POST['admin_pass']) && !empty($_POST['admin_pass'])) {
// Admin login attempt ?
else if(isset($_POST['admin_login'], $_POST['admin_username'], $_POST['admin_pass']) && !empty($_POST['admin_pass'])){
$req = $bdd->prepare('SELECT * FROM admin WHERE admin_id = ?'); $req = $bdd->prepare('SELECT * FROM admin WHERE admin_id = ?');
$req->execute(array($_POST['admin_username'])); $req->execute(array($_POST['admin_username']));
$data = $req->fetch(); $data = $req->fetch();
// Error ? // Error ?
if($data && passEqual($_POST['admin_pass'], $data['admin_pass'])) { if ($data && passEqual($_POST['admin_pass'], $data['admin_pass'])) {
$_SESSION['admin_id'] = $data['admin_id']; $_SESSION['admin_id'] = $data['admin_id'];
header("Location: index.php?admin"); header("Location: index.php?admin");
exit(-1); exit(-1);
} } else {
else { $error = true;
$error = true;
} }
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8"/>
<title>OpenVPN-Admin</title> <title>OpenVPN-Admin</title>
<link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css" /> <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css"/>
<link rel="stylesheet" href="/css/bootstrap-editable.css" type="text/css" /> <link rel="stylesheet" href="/css/bootstrap-editable.css" type="text/css"/>
<link rel="stylesheet" href="/css/bootstrap-table.min.css" type="text/css" /> <link rel="stylesheet" href="/css/bootstrap-table.min.css" type="text/css"/>
<link rel="stylesheet" href="/css/bootstrap-datepicker3.css" type="text/css" /> <link rel="stylesheet" href="/css/bootstrap-datepicker3.css" type="text/css"/>
<link rel="stylesheet" href="/css/index.css" type="text/css" /> <link rel="stylesheet" href="/css/index.css" type="text/css"/>
<link rel="icon" type="image/png" href="/img/icon.png"> <link rel="icon" type="image/png" href="/img/icon.png">
</head> </head>
<body class='container-fluid'> <body class='container-fluid'>
<?php <?php
// --------------- INSTALLATION --------------- // --------------- INSTALLATION ---------------
if(isset($_GET['installation'])) { if (isset($_GET['installation'])) {
if(isInstalled($bdd) == true) { if (isInstalled($bdd) == true) {
printError('OpenVPN-admin is already installed. Redirection.'); printError('OpenVPN-admin is already installed. Redirection.');
header( "refresh:3;url=index.php?admin" ); header("refresh:3;url=index.php?admin");
exit(-1); exit(-1);
} }
// If the user sent the installation form // If the user sent the installation form
if(isset($_POST['admin_username'])) { if (isset($_POST['admin_username'])) {
$admin_username = $_POST['admin_username']; $admin_username = $_POST['admin_username'];
$admin_pass = $_POST['admin_pass']; $admin_pass = $_POST['admin_pass'];
$admin_repeat_pass = $_POST['repeat_admin_pass']; $admin_repeat_pass = $_POST['repeat_admin_pass'];
if($admin_pass != $admin_repeat_pass) { if ($admin_pass != $admin_repeat_pass) {
printError('The passwords do not correspond. Redirection.'); printError('The passwords do not correspond. Redirection.');
header( "refresh:3;url=index.php?installation" ); header("refresh:3;url=index.php?installation");
exit(-1); exit(-1);
} }
// Create the initial tables // Create the initial tables
$migrations = getMigrationSchemas(); $migrations = getMigrationSchemas();
foreach ($migrations as $migration_value) { foreach ($migrations as $migration_value) {
$sql_file = dirname(__FILE__) . "/../scripts/sql/schema-$migration_value.sql"; $sql_file = dirname(__FILE__) . "/../scripts/sql/schema-$migration_value.sql";
try { try {
$sql = file_get_contents($sql_file); $sql = file_get_contents($sql_file);
$bdd->exec($sql); $bdd->exec($sql);
} } catch (PDOException $e) {
catch (PDOException $e) { printError($e->getMessage());
printError($e->getMessage()); exit(1);
exit(1); }
}
unlink($sql_file);
unlink($sql_file);
// Update schema to the new value
// Update schema to the new value updateSchema($bdd, $migration_value);
updateSchema($bdd, $migration_value);
} }
// Generate the hash // Generate the hash
@ -158,63 +154,60 @@
rmdir(dirname(__FILE__) . '/sql'); rmdir(dirname(__FILE__) . '/sql');
printSuccess('Well done, OpenVPN-Admin is installed. Redirection.'); printSuccess('Well done, OpenVPN-Admin is installed. Redirection.');
header( "refresh:3;url=index.php?admin" ); header("refresh:3;url=index.php?admin");
} } // Print the installation form
// Print the installation form else {
else { require(dirname(__FILE__) . '/../app/html/menu.php');
require(dirname(__FILE__) . '/../include/html/menu.php'); require(dirname(__FILE__) . '/../app/html/form/installation.php');
require(dirname(__FILE__) . '/../include/html/form/installation.php');
}
exit(-1);
}
// --------------- CONFIGURATION ---------------
if(!isset($_GET['admin'])) {
if(isset($error) && $error == true)
printError('Login error');
require(dirname(__FILE__) . '/../include/html/menu.php');
require(dirname(__FILE__) . '/../include/html/form/configuration.php');
} }
exit(-1);
}
// --------------- LOGIN --------------- // --------------- CONFIGURATION ---------------
else if(!isset($_SESSION['admin_id'])){ if (!isset($_GET['admin'])) {
if(isset($error) && $error == true) if (isset($error) && $error == true)
printError('Login error'); printError('Login error');
require(dirname(__FILE__) . '/../include/html/menu.php'); require(dirname(__FILE__) . '/../app/html/menu.php');
require(dirname(__FILE__) . '/../include/html/form/login.php'); require(dirname(__FILE__) . '/../app/html/form/configuration.php');
} } // --------------- LOGIN ---------------
else if (!isset($_SESSION['admin_id'])) {
if (isset($error) && $error == true)
printError('Login error');
// --------------- GRIDS --------------- require(dirname(__FILE__) . '/../app/html/menu.php');
else{ require(dirname(__FILE__) . '/../app/html/form/login.php');
?> } // --------------- GRIDS ---------------
<nav class="navbar navbar-default"> else {
?>
<nav class="navbar navbar-default">
<div class="row col-md-12"> <div class="row col-md-12">
<div class="col-md-6"> <div class="col-md-6">
<p class="navbar-text signed">Signed in as <?php echo $_SESSION['admin_id']; ?> <p class="navbar-text signed">Signed in as <?php echo $_SESSION['admin_id']; ?> </p>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<a class="navbar-text navbar-right" href="index.php?logout" title="Logout"><button class="btn btn-danger">Logout</button></a> <a class="navbar-text navbar-right" href="index.php?logout" title="Logout">
<a class="navbar-text navbar-right" href="index.php" title="Configuration"><button class="btn btn-default">Configurations</button></a> <button class="btn btn-danger">Logout</button>
</p> </a>
</div> <a class="navbar-text navbar-right" href="index.php" title="Configuration">
<button class="btn btn-default">Configurations</button>
</a>
</div>
</div> </div>
</nav> </nav>
<?php <?php
require(dirname(__FILE__) . '/../include/html/grids.php'); require(dirname(__FILE__) . '/../app/html/grids.php');
} }
?> ?>
<script src="/js/jquery.min.js"></script> <script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script> <script src="/js/bootstrap.min.js"></script>
<script src="/js/bootstrap-table.min.js"></script> <script src="/js/bootstrap-table.min.js"></script>
<script src="/js/bootstrap-datepicker.js"></script> <script src="/js/bootstrap-datepicker.js"></script>
<script src="/js/bootstrap-table-editable.min.js"></script> <script src="/js/bootstrap-table-editable.min.js"></script>
<script src="/js/bootstrap-editable.js"></script> <script src="/js/bootstrap-editable.js"></script>
<script src="/js/grids.js"></script> <script src="/js/grids.js"></script>
</body> </body>
</html> </html>

Loading…
Cancel
Save