From acd5ff0a23400c91f7df0e19829fb137b7b49a16 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Mon, 12 Aug 2024 14:12:24 +0300 Subject: [PATCH] Separates app code from public files. --- {public_html => app}/classes/component.php | 0 {public_html => app}/classes/conference.php | 0 {public_html => app}/classes/database.php | 0 {public_html => app}/classes/participant.php | 0 {public_html => app}/classes/queries.php | 0 {public_html => app}/classes/user.php | 0 .../config/jilo-web.conf.php | 2 +- app/config/routes.php | 0 config.apache => app/doc/config.apache | 0 config.nginx => app/doc/config.nginx | 0 install.sh => app/doc/install.sh | 0 jilo-web.schema => app/doc/jilo-web.schema | 0 {public_html => app}/helpers/database.php | 8 ++--- {public_html => app}/helpers/time_range.php | 0 {packaging => app/packaging}/build-deb | 0 {packaging => app/packaging}/build-rpm | 0 .../packaging}/deb-README.debian | 0 {packaging => app/packaging}/deb-config | 0 {packaging => app/packaging}/deb-control | 0 {packaging => app/packaging}/deb-postinst | 0 {packaging => app/packaging}/deb-postrm | 0 {packaging => app/packaging}/deb-templates | 0 {packaging => app/packaging}/man-jilo-web.8 | 0 .../packaging}/rpm-jilo-web.spec | 0 {public_html => app}/pages/components.php | 10 +++--- {public_html => app}/pages/conferences.php | 10 +++--- app/pages/config.php | 5 +++ {public_html => app}/pages/front.php | 14 ++++----- {public_html => app}/pages/login.php | 10 +++--- {public_html => app}/pages/participants.php | 10 +++--- app/pages/profile.php | 5 +++ {public_html => app}/pages/register.php | 12 +++---- .../templates/block-message.php | 0 .../templates/block-results-filter.php | 0 {public_html => app}/templates/form-login.php | 0 .../templates/form-register.php | 0 .../templates/page-footer.php | 0 .../templates/page-header.php | 0 {public_html => app}/templates/page-menu.php | 0 .../templates/page-sidebar.php | 0 .../templates/widget-config.php | 0 .../templates/widget-monthly.php | 2 +- .../templates/widget-profile.php | 0 {public_html => app}/templates/widget.php | 2 +- public_html/index.php | 31 ++++++++++--------- public_html/pages/config.php | 5 --- public_html/pages/profile.php | 5 --- 47 files changed, 66 insertions(+), 65 deletions(-) rename {public_html => app}/classes/component.php (100%) rename {public_html => app}/classes/conference.php (100%) rename {public_html => app}/classes/database.php (100%) rename {public_html => app}/classes/participant.php (100%) rename {public_html => app}/classes/queries.php (100%) rename {public_html => app}/classes/user.php (100%) rename jilo-web.conf.php => app/config/jilo-web.conf.php (85%) create mode 100644 app/config/routes.php rename config.apache => app/doc/config.apache (100%) rename config.nginx => app/doc/config.nginx (100%) rename install.sh => app/doc/install.sh (100%) rename jilo-web.schema => app/doc/jilo-web.schema (100%) rename {public_html => app}/helpers/database.php (87%) rename {public_html => app}/helpers/time_range.php (100%) rename {packaging => app/packaging}/build-deb (100%) rename {packaging => app/packaging}/build-rpm (100%) rename {packaging => app/packaging}/deb-README.debian (100%) rename {packaging => app/packaging}/deb-config (100%) rename {packaging => app/packaging}/deb-control (100%) rename {packaging => app/packaging}/deb-postinst (100%) rename {packaging => app/packaging}/deb-postrm (100%) rename {packaging => app/packaging}/deb-templates (100%) rename {packaging => app/packaging}/man-jilo-web.8 (100%) rename {packaging => app/packaging}/rpm-jilo-web.spec (100%) rename {public_html => app}/pages/components.php (91%) rename {public_html => app}/pages/conferences.php (95%) create mode 100644 app/pages/config.php rename {public_html => app}/pages/front.php (94%) rename {public_html => app}/pages/login.php (89%) rename {public_html => app}/pages/participants.php (96%) create mode 100644 app/pages/profile.php rename {public_html => app}/pages/register.php (77%) rename {public_html => app}/templates/block-message.php (100%) rename {public_html => app}/templates/block-results-filter.php (100%) rename {public_html => app}/templates/form-login.php (100%) rename {public_html => app}/templates/form-register.php (100%) rename {public_html => app}/templates/page-footer.php (100%) rename {public_html => app}/templates/page-header.php (100%) rename {public_html => app}/templates/page-menu.php (100%) rename {public_html => app}/templates/page-sidebar.php (100%) rename {public_html => app}/templates/widget-config.php (100%) rename {public_html => app}/templates/widget-monthly.php (98%) rename {public_html => app}/templates/widget-profile.php (100%) rename {public_html => app}/templates/widget.php (98%) delete mode 100644 public_html/pages/config.php delete mode 100644 public_html/pages/profile.php diff --git a/public_html/classes/component.php b/app/classes/component.php similarity index 100% rename from public_html/classes/component.php rename to app/classes/component.php diff --git a/public_html/classes/conference.php b/app/classes/conference.php similarity index 100% rename from public_html/classes/conference.php rename to app/classes/conference.php diff --git a/public_html/classes/database.php b/app/classes/database.php similarity index 100% rename from public_html/classes/database.php rename to app/classes/database.php diff --git a/public_html/classes/participant.php b/app/classes/participant.php similarity index 100% rename from public_html/classes/participant.php rename to app/classes/participant.php diff --git a/public_html/classes/queries.php b/app/classes/queries.php similarity index 100% rename from public_html/classes/queries.php rename to app/classes/queries.php diff --git a/public_html/classes/user.php b/app/classes/user.php similarity index 100% rename from public_html/classes/user.php rename to app/classes/user.php diff --git a/jilo-web.conf.php b/app/config/jilo-web.conf.php similarity index 85% rename from jilo-web.conf.php rename to app/config/jilo-web.conf.php index b581160..3eb2f16 100644 --- a/jilo-web.conf.php +++ b/app/config/jilo-web.conf.php @@ -7,7 +7,7 @@ $config = [ 'db_type' => 'sqlite', - 'sqlite_file' => '../jilo-web.db', + 'sqlite_file' => '../app/jilo-web.db', 'registration_enabled' => true, 'login_message' => '', diff --git a/app/config/routes.php b/app/config/routes.php new file mode 100644 index 0000000..e69de29 diff --git a/config.apache b/app/doc/config.apache similarity index 100% rename from config.apache rename to app/doc/config.apache diff --git a/config.nginx b/app/doc/config.nginx similarity index 100% rename from config.nginx rename to app/doc/config.nginx diff --git a/install.sh b/app/doc/install.sh similarity index 100% rename from install.sh rename to app/doc/install.sh diff --git a/jilo-web.schema b/app/doc/jilo-web.schema similarity index 100% rename from jilo-web.schema rename to app/doc/jilo-web.schema diff --git a/public_html/helpers/database.php b/app/helpers/database.php similarity index 87% rename from public_html/helpers/database.php rename to app/helpers/database.php index 8b3486d..b382134 100644 --- a/public_html/helpers/database.php +++ b/app/helpers/database.php @@ -11,7 +11,7 @@ function connectDB($config, $database = '') { ]); } catch (Exception $e) { $error = 'Error: ' . $e->getMessage(); - include 'templates/block-message.php'; + include '../app/templates/block-message.php'; exit(); } @@ -27,7 +27,7 @@ function connectDB($config, $database = '') { $pdo = $db->getConnection(); } catch (Exception $e) { $error = 'Error: ' . $e->getMessage(); - include 'templates/block-message.php'; + include '../app/templates/block-message.php'; exit(); } // mysql/mariadb database @@ -44,13 +44,13 @@ function connectDB($config, $database = '') { $pdo = $db->getConnection(); } catch (Exception $e) { $error = 'Error: ' . $e->getMessage(); - include 'templates/block-message.php'; + include '../app/templates/block-message.php'; exit(); } // unknown database } else { $error = "Error: unknow database type \"{$config['db_type']}\""; - include 'templates/block-message.php'; + include '../app/templates/block-message.php'; exit(); } diff --git a/public_html/helpers/time_range.php b/app/helpers/time_range.php similarity index 100% rename from public_html/helpers/time_range.php rename to app/helpers/time_range.php diff --git a/packaging/build-deb b/app/packaging/build-deb similarity index 100% rename from packaging/build-deb rename to app/packaging/build-deb diff --git a/packaging/build-rpm b/app/packaging/build-rpm similarity index 100% rename from packaging/build-rpm rename to app/packaging/build-rpm diff --git a/packaging/deb-README.debian b/app/packaging/deb-README.debian similarity index 100% rename from packaging/deb-README.debian rename to app/packaging/deb-README.debian diff --git a/packaging/deb-config b/app/packaging/deb-config similarity index 100% rename from packaging/deb-config rename to app/packaging/deb-config diff --git a/packaging/deb-control b/app/packaging/deb-control similarity index 100% rename from packaging/deb-control rename to app/packaging/deb-control diff --git a/packaging/deb-postinst b/app/packaging/deb-postinst similarity index 100% rename from packaging/deb-postinst rename to app/packaging/deb-postinst diff --git a/packaging/deb-postrm b/app/packaging/deb-postrm similarity index 100% rename from packaging/deb-postrm rename to app/packaging/deb-postrm diff --git a/packaging/deb-templates b/app/packaging/deb-templates similarity index 100% rename from packaging/deb-templates rename to app/packaging/deb-templates diff --git a/packaging/man-jilo-web.8 b/app/packaging/man-jilo-web.8 similarity index 100% rename from packaging/man-jilo-web.8 rename to app/packaging/man-jilo-web.8 diff --git a/packaging/rpm-jilo-web.spec b/app/packaging/rpm-jilo-web.spec similarity index 100% rename from packaging/rpm-jilo-web.spec rename to app/packaging/rpm-jilo-web.spec diff --git a/public_html/pages/components.php b/app/pages/components.php similarity index 91% rename from public_html/pages/components.php rename to app/pages/components.php index 245e5cb..bc2fbf1 100644 --- a/public_html/pages/components.php +++ b/app/pages/components.php @@ -1,14 +1,14 @@ diff --git a/public_html/pages/conferences.php b/app/pages/conferences.php similarity index 95% rename from public_html/pages/conferences.php rename to app/pages/conferences.php index f868545..f67a6d0 100644 --- a/public_html/pages/conferences.php +++ b/app/pages/conferences.php @@ -1,14 +1,14 @@ diff --git a/app/pages/config.php b/app/pages/config.php new file mode 100644 index 0000000..8a3c8a8 --- /dev/null +++ b/app/pages/config.php @@ -0,0 +1,5 @@ + diff --git a/public_html/pages/front.php b/app/pages/front.php similarity index 94% rename from public_html/pages/front.php rename to app/pages/front.php index d4a0652..21c97a2 100644 --- a/public_html/pages/front.php +++ b/app/pages/front.php @@ -1,11 +1,11 @@ diff --git a/public_html/pages/login.php b/app/pages/login.php similarity index 89% rename from public_html/pages/login.php rename to app/pages/login.php index 633cfaf..6d9f5ef 100644 --- a/public_html/pages/login.php +++ b/app/pages/login.php @@ -1,7 +1,7 @@ diff --git a/public_html/pages/participants.php b/app/pages/participants.php similarity index 96% rename from public_html/pages/participants.php rename to app/pages/participants.php index 3ca6521..0a0966b 100644 --- a/public_html/pages/participants.php +++ b/app/pages/participants.php @@ -1,14 +1,14 @@ diff --git a/app/pages/profile.php b/app/pages/profile.php new file mode 100644 index 0000000..09a67af --- /dev/null +++ b/app/pages/profile.php @@ -0,0 +1,5 @@ + diff --git a/public_html/pages/register.php b/app/pages/register.php similarity index 77% rename from public_html/pages/register.php rename to app/pages/register.php index 1b7a560..d6be857 100644 --- a/public_html/pages/register.php +++ b/app/pages/register.php @@ -3,14 +3,14 @@ // registration is allowed, go on if ($config['registration_enabled'] === true) { - require_once 'classes/database.php'; - require 'classes/user.php'; + require_once '../app/classes/database.php'; + require '../app/classes/user.php'; unset($error); try { // connect to database - require 'helpers/database.php'; + require '../app/helpers/database.php'; $db = connectDB($config); $user = new User($db); @@ -35,13 +35,13 @@ if ($config['registration_enabled'] === true) { $error = $e->getMessage(); } - include 'templates/block-message.php'; - include 'templates/form-register.php'; + include '../app/templates/block-message.php'; + include '../app/templates/form-register.php'; // registration disabled } else { $notice = 'Registration is disabled'; - include 'templates/block-message.php'; + include '../app/templates/block-message.php'; } ?> diff --git a/public_html/templates/block-message.php b/app/templates/block-message.php similarity index 100% rename from public_html/templates/block-message.php rename to app/templates/block-message.php diff --git a/public_html/templates/block-results-filter.php b/app/templates/block-results-filter.php similarity index 100% rename from public_html/templates/block-results-filter.php rename to app/templates/block-results-filter.php diff --git a/public_html/templates/form-login.php b/app/templates/form-login.php similarity index 100% rename from public_html/templates/form-login.php rename to app/templates/form-login.php diff --git a/public_html/templates/form-register.php b/app/templates/form-register.php similarity index 100% rename from public_html/templates/form-register.php rename to app/templates/form-register.php diff --git a/public_html/templates/page-footer.php b/app/templates/page-footer.php similarity index 100% rename from public_html/templates/page-footer.php rename to app/templates/page-footer.php diff --git a/public_html/templates/page-header.php b/app/templates/page-header.php similarity index 100% rename from public_html/templates/page-header.php rename to app/templates/page-header.php diff --git a/public_html/templates/page-menu.php b/app/templates/page-menu.php similarity index 100% rename from public_html/templates/page-menu.php rename to app/templates/page-menu.php diff --git a/public_html/templates/page-sidebar.php b/app/templates/page-sidebar.php similarity index 100% rename from public_html/templates/page-sidebar.php rename to app/templates/page-sidebar.php diff --git a/public_html/templates/widget-config.php b/app/templates/widget-config.php similarity index 100% rename from public_html/templates/widget-config.php rename to app/templates/widget-config.php diff --git a/public_html/templates/widget-monthly.php b/app/templates/widget-monthly.php similarity index 98% rename from public_html/templates/widget-monthly.php rename to app/templates/widget-monthly.php index 0caae35..467a66f 100644 --- a/public_html/templates/widget-monthly.php +++ b/app/templates/widget-monthly.php @@ -8,7 +8,7 @@
+ include('../app/templates/block-results-filter.php'); } ?> diff --git a/public_html/templates/widget-profile.php b/app/templates/widget-profile.php similarity index 100% rename from public_html/templates/widget-profile.php rename to app/templates/widget-profile.php diff --git a/public_html/templates/widget.php b/app/templates/widget.php similarity index 98% rename from public_html/templates/widget.php rename to app/templates/widget.php index ed33769..60ff393 100644 --- a/public_html/templates/widget.php +++ b/app/templates/widget.php @@ -7,7 +7,7 @@
+ include('../app/templates/block-results-filter.php'); } ?> diff --git a/public_html/index.php b/public_html/index.php index 070210f..d53a37d 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -33,6 +33,7 @@ $allowed_urls = [ // cnfig file // possible locations, in order of preference $config_file_locations = [ + __DIR__ . '/../app/config/jilo-web.conf.php', __DIR__ . '/../jilo-web.conf.php', '/srv/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); $notice = "You were logged out.
You can log in again."; - include 'templates/page-header.php'; - include 'templates/page-menu.php'; - include 'templates/block-message.php'; - include 'pages/login.php'; + include '../app/templates/page-header.php'; + include '../app/templates/page-menu.php'; + include '../app/templates/block-message.php'; + include '../app/pages/login.php'; // all other normal pages } else { - include 'templates/page-header.php'; - include 'templates/page-menu.php'; - include 'templates/block-message.php'; + include '../app/templates/page-header.php'; + include '../app/templates/page-menu.php'; + include '../app/templates/block-message.php'; 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 } else { $error = 'The page "' . $page . '" is not found'; - include 'templates/page-header.php'; - include 'templates/page-menu.php'; - include 'templates/block-message.php'; + include '../app/templates/page-header.php'; + include '../app/templates/page-menu.php'; + include '../app/templates/block-message.php'; 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 unset($_SESSION['error']); diff --git a/public_html/pages/config.php b/public_html/pages/config.php deleted file mode 100644 index c562a1a..0000000 --- a/public_html/pages/config.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/public_html/pages/profile.php b/public_html/pages/profile.php deleted file mode 100644 index 92f835f..0000000 --- a/public_html/pages/profile.php +++ /dev/null @@ -1,5 +0,0 @@ -