Separates app code from public files.

main
Yasen Pramatarov 2024-08-12 14:12:24 +03:00
parent 9a3024cfa6
commit acd5ff0a23
47 changed files with 66 additions and 65 deletions

View File

@ -7,7 +7,7 @@ $config = [
'db_type' => 'sqlite', 'db_type' => 'sqlite',
'sqlite_file' => '../jilo-web.db', 'sqlite_file' => '../app/jilo-web.db',
'registration_enabled' => true, 'registration_enabled' => true,
'login_message' => '', 'login_message' => '',

View File

View File

@ -11,7 +11,7 @@ function connectDB($config, $database = '') {
]); ]);
} catch (Exception $e) { } catch (Exception $e) {
$error = 'Error: ' . $e->getMessage(); $error = 'Error: ' . $e->getMessage();
include 'templates/block-message.php'; include '../app/templates/block-message.php';
exit(); exit();
} }
@ -27,7 +27,7 @@ function connectDB($config, $database = '') {
$pdo = $db->getConnection(); $pdo = $db->getConnection();
} catch (Exception $e) { } catch (Exception $e) {
$error = 'Error: ' . $e->getMessage(); $error = 'Error: ' . $e->getMessage();
include 'templates/block-message.php'; include '../app/templates/block-message.php';
exit(); exit();
} }
// mysql/mariadb database // mysql/mariadb database
@ -44,13 +44,13 @@ function connectDB($config, $database = '') {
$pdo = $db->getConnection(); $pdo = $db->getConnection();
} catch (Exception $e) { } catch (Exception $e) {
$error = 'Error: ' . $e->getMessage(); $error = 'Error: ' . $e->getMessage();
include 'templates/block-message.php'; include '../app/templates/block-message.php';
exit(); exit();
} }
// unknown database // unknown database
} else { } else {
$error = "Error: unknow database type \"{$config['db_type']}\""; $error = "Error: unknow database type \"{$config['db_type']}\"";
include 'templates/block-message.php'; include '../app/templates/block-message.php';
exit(); exit();
} }

View File

@ -1,14 +1,14 @@
<?php <?php
require_once 'classes/database.php'; require_once '../app/classes/database.php';
require 'classes/component.php'; require '../app/classes/component.php';
// connect to database // connect to database
require 'helpers/database.php'; require '../app/helpers/database.php';
$db = connectDB($config, 'jilo'); $db = connectDB($config, 'jilo');
// specify time range // specify time range
include 'helpers/time_range.php'; include '../app/helpers/time_range.php';
// jitsi component events list // jitsi component events list
// we use $_REQUEST, so that both links and forms work // we use $_REQUEST, so that both links and forms work
@ -79,6 +79,6 @@ if (!empty($components['records'])) {
} }
// display the widget // display the widget
include('templates/widget.php'); include('../app/templates/widget.php');
?> ?>

View File

@ -1,14 +1,14 @@
<?php <?php
require_once 'classes/database.php'; require_once '../app/classes/database.php';
require 'classes/conference.php'; require '../app/classes/conference.php';
// connect to database // connect to database
require 'helpers/database.php'; require '../app/helpers/database.php';
$db = connectDB($config, 'jilo'); $db = connectDB($config, 'jilo');
// specify time range // specify time range
include 'helpers/time_range.php'; include '../app/helpers/time_range.php';
// conference id/name are specified when searching specific conference(s) // conference id/name are specified when searching specific conference(s)
// either id OR name, id has precedence // either id OR name, id has precedence
@ -128,6 +128,6 @@ if (!empty($conferences['records'])) {
} }
// display the widget // display the widget
include('templates/widget.php'); include('../app/templates/widget.php');
?> ?>

View File

@ -0,0 +1,5 @@
<?php
include('../app/templates/widget-config.php');
?>

View File

@ -1,11 +1,11 @@
<?php <?php
require_once 'classes/database.php'; require_once '../app/classes/database.php';
require 'classes/conference.php'; require '../app/classes/conference.php';
require 'classes/participant.php'; require '../app/classes/participant.php';
// connect to database // connect to database
require 'helpers/database.php'; require '../app/helpers/database.php';
$db = connectDB($config, 'jilo'); $db = connectDB($config, 'jilo');
@ -73,7 +73,7 @@ if (!empty($searchConferenceNumber) && !empty($searchParticipantNumber)) {
} }
// display the widget // display the widget
include('templates/widget-monthly.php'); include('../app/templates/widget-monthly.php');
//// ////
@ -132,7 +132,7 @@ if (!empty($conferences['records'])) {
} }
// display the widget // display the widget
include('templates/widget.php'); include('../app/templates/widget.php');
//// ////
@ -199,6 +199,6 @@ if (!empty($conferences['records'])) {
} }
// display the widget // display the widget
include('templates/widget.php'); include('../app/templates/widget.php');
?> ?>

View File

@ -1,7 +1,7 @@
<?php <?php
require_once 'classes/database.php'; require_once '../app/classes/database.php';
require 'classes/user.php'; require '../app/classes/user.php';
// clear the global error var before login // clear the global error var before login
unset($error); unset($error);
@ -9,7 +9,7 @@ unset($error);
try { try {
// connect to database // connect to database
require 'helpers/database.php'; require '../app/helpers/database.php';
$db = connectDB($config); $db = connectDB($config);
$user = new User($db); $user = new User($db);
@ -62,9 +62,9 @@ try {
if (!empty($config['login_message'])) { if (!empty($config['login_message'])) {
$notice = $config['login_message']; $notice = $config['login_message'];
include 'templates/block-message.php'; include '../app/templates/block-message.php';
} }
include 'templates/form-login.php'; include '../app/templates/form-login.php';
?> ?>

View File

@ -1,14 +1,14 @@
<?php <?php
require_once 'classes/database.php'; require_once '../app/classes/database.php';
require 'classes/participant.php'; require '../app/classes/participant.php';
// connect to database // connect to database
require 'helpers/database.php'; require '../app/helpers/database.php';
$db = connectDB($config, 'jilo'); $db = connectDB($config, 'jilo');
// specify time range // specify time range
include 'helpers/time_range.php'; include '../app/helpers/time_range.php';
// participant id/name/IP are specified when searching specific participant(s) // participant id/name/IP are specified when searching specific participant(s)
// participant name - this is 'stats_id' in the db // participant name - this is 'stats_id' in the db
@ -137,6 +137,6 @@ if (!empty($participants['records'])) {
} }
// display the widget // display the widget
include('templates/widget.php'); include('../app/templates/widget.php');
?> ?>

View File

@ -0,0 +1,5 @@
<?php
include('../app/templates/widget-profile.php');
?>

View File

@ -3,14 +3,14 @@
// registration is allowed, go on // registration is allowed, go on
if ($config['registration_enabled'] === true) { if ($config['registration_enabled'] === true) {
require_once 'classes/database.php'; require_once '../app/classes/database.php';
require 'classes/user.php'; require '../app/classes/user.php';
unset($error); unset($error);
try { try {
// connect to database // connect to database
require 'helpers/database.php'; require '../app/helpers/database.php';
$db = connectDB($config); $db = connectDB($config);
$user = new User($db); $user = new User($db);
@ -35,13 +35,13 @@ if ($config['registration_enabled'] === true) {
$error = $e->getMessage(); $error = $e->getMessage();
} }
include 'templates/block-message.php'; include '../app/templates/block-message.php';
include 'templates/form-register.php'; include '../app/templates/form-register.php';
// registration disabled // registration disabled
} else { } else {
$notice = 'Registration is disabled'; $notice = 'Registration is disabled';
include 'templates/block-message.php'; include '../app/templates/block-message.php';
} }
?> ?>

View File

@ -8,7 +8,7 @@
<div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div> <div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div>
<?php } ?> <?php } ?>
<?php if ($widget['filter'] === true) { <?php if ($widget['filter'] === true) {
include('templates/block-results-filter.php'); } ?> include('../app/templates/block-results-filter.php'); } ?>
<?php if ($widget['collapsible'] === true) { ?> <?php if ($widget['collapsible'] === true) { ?>
</a> </a>
<?php } ?> <?php } ?>

View File

@ -7,7 +7,7 @@
<div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div> <div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div>
<?php } ?> <?php } ?>
<?php if ($widget['filter'] === true) { <?php if ($widget['filter'] === true) {
include('templates/block-results-filter.php'); } ?> include('../app/templates/block-results-filter.php'); } ?>
<?php if ($widget['collapsible'] === true) { ?> <?php if ($widget['collapsible'] === true) { ?>
</a> </a>
<?php } ?> <?php } ?>

View File

@ -33,6 +33,7 @@ $allowed_urls = [
// cnfig file // cnfig file
// possible locations, in order of preference // possible locations, in order of preference
$config_file_locations = [ $config_file_locations = [
__DIR__ . '/../app/config/jilo-web.conf.php',
__DIR__ . '/../jilo-web.conf.php', __DIR__ . '/../jilo-web.conf.php',
'/srv/jilo-web/jilo-web.conf.php', '/srv/jilo-web/jilo-web.conf.php',
'/opt/jilo-web/jilo-web.conf.php' '/opt/jilo-web/jilo-web.conf.php'
@ -99,34 +100,34 @@ if (in_array($page, $allowed_urls)) {
setcookie('username', "", time() - 100, $config['folder'], $config['domain'], isset($_SERVER['HTTPS']), true); setcookie('username', "", time() - 100, $config['folder'], $config['domain'], isset($_SERVER['HTTPS']), true);
$notice = "You were logged out.<br />You can log in again."; $notice = "You were logged out.<br />You can log in again.";
include 'templates/page-header.php'; include '../app/templates/page-header.php';
include 'templates/page-menu.php'; include '../app/templates/page-menu.php';
include 'templates/block-message.php'; include '../app/templates/block-message.php';
include 'pages/login.php'; include '../app/pages/login.php';
// all other normal pages // all other normal pages
} else { } else {
include 'templates/page-header.php'; include '../app/templates/page-header.php';
include 'templates/page-menu.php'; include '../app/templates/page-menu.php';
include 'templates/block-message.php'; include '../app/templates/block-message.php';
if (isset($user)) { if (isset($user)) {
include 'templates/page-sidebar.php'; include '../app/templates/page-sidebar.php';
} }
include "pages/{$page}.php"; include "../app/pages/{$page}.php";
} }
// the page is not in allowed urls, loading front page // the page is not in allowed urls, loading front page
} else { } else {
$error = 'The page "' . $page . '" is not found'; $error = 'The page "' . $page . '" is not found';
include 'templates/page-header.php'; include '../app/templates/page-header.php';
include 'templates/page-menu.php'; include '../app/templates/page-menu.php';
include 'templates/block-message.php'; include '../app/templates/block-message.php';
if (isset($user)) { if (isset($user)) {
include 'templates/page-sidebar.php'; include '../app/templates/page-sidebar.php';
} }
include 'pages/front.php'; include '../app/pages/front.php';
} }
include 'templates/page-footer.php'; include '../app/templates/page-footer.php';
// clear errors and notices before next page just in case // clear errors and notices before next page just in case
unset($_SESSION['error']); unset($_SESSION['error']);

View File

@ -1,5 +0,0 @@
<?php
include('templates/widget-config.php');
?>

View File

@ -1,5 +0,0 @@
<?php
include('templates/widget-profile.php');
?>