Skip to content

Commit

Permalink
fix(admin-panels): include paths
Browse files Browse the repository at this point in the history
  • Loading branch information
danielebriggi committed Jul 29, 2024
1 parent d70e028 commit 33b8984
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 52 deletions.
5 changes: 4 additions & 1 deletion admin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
session_set_cookie_params(0);
session_start();

echo var_dump($_SESSION);

// check if there is no valid session or if session is expired
$session_max_time = 60 * 600; // 60 minutes
if ((!isset($_SESSION['username'])) || (isset($_SESSION['start']) && (time() - $_SESSION['start'] >= $session_max_time))) {
session_unset();
session_destroy();
header("Location: login.php");
echo var_dump($_SESSION);
//header("Location: login.php");
exit();
}
4 changes: 2 additions & 2 deletions admin/backups.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand All @@ -12,4 +12,4 @@

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/commands.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand All @@ -12,4 +12,4 @@

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/connections.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand All @@ -12,4 +12,4 @@

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/console.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand Down Expand Up @@ -34,4 +34,4 @@
global $jsinclude;
$jsinclude = "console.js";
?>
<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/console_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use SQLiteCloud\SQLiteCloudRowset;

include_once('auth.php');
include_once('common.php');
include_once(__DIR__ . '/auth.php');
include_once(__DIR__ . '/common.php');

$data = json_decode(file_get_contents('php://input'), true);
$database = $data["database"];
Expand Down
4 changes: 2 additions & 2 deletions admin/databases.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand Down Expand Up @@ -46,4 +46,4 @@ function on_column($value, $row, $col)
global $jsinclude;
$jsinclude = "upload.js";
?>
<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
2 changes: 1 addition & 1 deletion admin/download.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

include_once('common.php');
include_once(__DIR__ . '/common.php');
$dbName = $_GET['db'];
$maxRead = 1 * 1024 * 1024; // 1MB
$dbSize = 0;
Expand Down
18 changes: 9 additions & 9 deletions admin/include/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
<script src="dashboard.js"></script>
<?php
global $jscript;
global $jsinclude;
global $jsinclude;

if (isset($jscript)) {
echo '<script>' . $jscript . '</script>';
}
if (isset($jsinclude)) {
echo '<script src="' . $jsinclude . '"></script>';
}
echo "\n";
?>
if (isset($jscript)) {
echo '<script>' . $jscript . '</script>';
}
if (isset($jsinclude)) {
echo '<script src="' . $jsinclude . '"></script>';
}
echo "\n";
?>
</body>
</html>

Expand Down
4 changes: 2 additions & 2 deletions admin/include/header.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
include_once('auth.php');
include_once('common.php');
include_once(__DIR__ . '/../auth.php');
include_once(__DIR__ . '/../common.php');
$page = current_page();
?>

Expand Down
4 changes: 2 additions & 2 deletions admin/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand All @@ -21,4 +21,4 @@

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/latency.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand All @@ -12,4 +12,4 @@

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
2 changes: 1 addition & 1 deletion admin/login.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('common.php'); ?>
<?php include_once(__DIR__ . '/common.php'); ?>
<!doctype html>
<html lang="en">
<head>
Expand Down
6 changes: 3 additions & 3 deletions admin/login_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
$password = $data["password"];
$port = $data["port"];

include_once('common.php');
include_once(__DIR__ . '/common.php');
$rc = do_real_connect($hostname, $port, $username, $password);

$r = null;
if ($rc === true) {
// successfully connected
$r = array('result' => 1);
$r = ['result' => 1];
$_SESSION['start'] = time();
$_SESSION['port'] = $port;
$_SESSION['hostname'] = $hostname;
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
} else {
// error
$r = array('result' => 0, 'msg' => $rc);
$r = ['result' => 0, 'msg' => $rc];
}

echo json_encode($r);
4 changes: 2 additions & 2 deletions admin/logs.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand Down Expand Up @@ -43,4 +43,4 @@ function on_column($value, $row, $col)

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/plugins.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand All @@ -12,4 +12,4 @@

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/settings.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand All @@ -12,4 +12,4 @@

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/stats.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
<?php $rs = query_liststats(); ?>
Expand Down Expand Up @@ -34,4 +34,4 @@
$jscript = $script1 . "\n" . $script2 . "\n" . $script3 . "\n" . $script4 . "\n";
?>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
4 changes: 2 additions & 2 deletions admin/upload_action.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

include_once('auth.php');
include_once('common.php');
include_once(__DIR__ . '/auth.php');
include_once(__DIR__ . '/common.php');

function do_upload_loop()
{
Expand Down
4 changes: 2 additions & 2 deletions admin/users.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include_once('include/header.php'); ?>
<?php include_once(__DIR__ . '/include/header.php'); ?>

<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">

Expand All @@ -12,4 +12,4 @@

</main>

<?php include_once('include/footer.php'); ?>
<?php include_once(__DIR__ . '/include/footer.php'); ?>
14 changes: 7 additions & 7 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": 2,
"builds": [
{
"src": "admin/**/*.php",
"use": "[email protected]",
"config": {
"includeFiles": [
"admin/**/*"
]
}
"use": "[email protected]"
},
{
"src": "admin/**/*",
"use": "@vercel/static"
}
],
"routes": [
Expand All @@ -16,4 +16,4 @@
"dest": "/admin/$1"
}
]
}
}

0 comments on commit 33b8984

Please sign in to comment.