From 2385b8295a3f7f85655321dae3f4c4acc247c2c9 Mon Sep 17 00:00:00 2001
From: Dominik <163560221+Dominik-developer@users.noreply.github.com>
Date: Tue, 7 Jan 2025 22:04:55 +0100
Subject: [PATCH 01/21] New structure of files, change names of some files,
rebuild part of the system, new functions, part of version v1.2.0
---
admin/{ => CSS}/panel.css | 35 +--
admin/CSS/window.css | 272 +++++++++++++++++++++
admin/JS/index.js | 42 ++++
admin/{ => algo}/dashboard.alg.php | 4 +-
admin/algo/edit.alg.php | 21 ++
admin/algo/new.alg.php | 150 ++++++++++++
admin/{ => algo}/password.alg.php | 21 +-
admin/{ => algo}/service_status.alg.php | 15 +-
admin/all_articles.alg.php | 98 ++++----
admin/index.js | 89 -------
admin/{ => old}/functions.php | 17 +-
admin/{ => old}/main.css | 30 +--
admin/{new.alg.php => old/new.alg.new.php} | 40 +--
admin/panel.login.css | 32 +--
admin/panel.login.php | 15 +-
admin/panel.logout.alg.php | 4 +-
admin/panel.php | 113 +++++----
admin/panel_login.alg.php | 16 +-
admin/test.new.php | 3 -
admin/window_functions.php | 266 ++++++++++++++++++++
20 files changed, 969 insertions(+), 314 deletions(-)
rename admin/{ => CSS}/panel.css (85%)
create mode 100644 admin/CSS/window.css
create mode 100644 admin/JS/index.js
rename admin/{ => algo}/dashboard.alg.php (85%)
create mode 100644 admin/algo/edit.alg.php
create mode 100644 admin/algo/new.alg.php
rename admin/{ => algo}/password.alg.php (77%)
rename admin/{ => algo}/service_status.alg.php (77%)
delete mode 100644 admin/index.js
rename admin/{ => old}/functions.php (95%)
rename admin/{ => old}/main.css (91%)
rename admin/{new.alg.php => old/new.alg.new.php} (85%)
delete mode 100644 admin/test.new.php
create mode 100644 admin/window_functions.php
diff --git a/admin/panel.css b/admin/CSS/panel.css
similarity index 85%
rename from admin/panel.css
rename to admin/CSS/panel.css
index 4f12804..593a6a6 100644
--- a/admin/panel.css
+++ b/admin/CSS/panel.css
@@ -10,10 +10,11 @@
body {
min-height: 100%;
- background-color: lightgray;
+ background-color: #fff;
padding-top: 70px;
}
+/* nav, menu */
nav {
position: fixed;
top: 0;
@@ -22,7 +23,7 @@ nav {
width: 100%;
display: flex;
align-items: center;
- background-color: #fff;
+ background-color: #4070f4;
box-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
}
@@ -39,6 +40,11 @@ nav .logo {
cursor: pointer;
}
+.menu-icon.topbar,
+span.logo-name.topbar{
+ color: #fff;
+}
+
.logo .logo-name {
color: #333;
font-size: 22px;
@@ -55,7 +61,7 @@ nav .sidebar {
/*opacity: 0.5;*/
background-color: #fff;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
- transition: all 0.4s ease; /* 0.5s */
+ transition: all 0.4s ease;
}
nav.open .sidebar {
@@ -123,45 +129,26 @@ nav.open ~ .overlay {
z-index: 100;
}
-
/* main */
main {
width: 100%;
height: calc(100vh - 70px);
- /*height: 100vh;*/
- /*height: calc(100%-70px);*/
- /*height: 1000px;*/
- /*background-color: blue;*/
- padding: 20px;
-}
-
-main section.section {
- /*border: solid 1px black;*/
- width: 100%;
- height: 100%;
- /*padding: 10px;*/
+ background-color: #fff;
}
-
-/*.bottom-content .list .nav-link span.link:hover,
-.bottom-content .list .nav-link .icon:hover{
- color: #fff;
-}*/
-
.bottom-content .list .nav-link:hover{
background-color: #4070f4;
color: #fff ;
}
+
.list .nav-link:hover .icon,
.list .nav-link:hover .link{
color: white;
}
-
.bottom-content .list .nav-link#logOut:hover{
background-color: white;
color: #707070;
-
}
.list .nav-link:hover .icon.logOut,
diff --git a/admin/CSS/window.css b/admin/CSS/window.css
new file mode 100644
index 0000000..2ef7754
--- /dev/null
+++ b/admin/CSS/window.css
@@ -0,0 +1,272 @@
+
+/* === general window === */
+article.window {
+ display: block;
+ width: 100%;
+ height: 100%;
+}
+
+.main {
+ padding: 20px;
+ background-color: #fff; /* Kolor tła sekcji */
+ height: 100%;
+}
+
+/** window name */
+.main h2 {
+ margin-bottom: 20px;
+ font-size: 24px;
+ color: #333; /* Kolor nagłówka */
+}
+
+/** window content */
+.main .content {
+ padding: 20px;
+ background-color: #f2f2f2; /* Kolor tła wewnętrznej sekcji */
+ border-radius: 8px;
+ box-sizing: border-box;
+ margin-top: 10px;
+ margin-bottom: 10px;
+ color: #333;
+ font-size: 16px;
+ height: 90%;
+}
+
+
+/* === GLOBAL STYLES ==== */
+.content {
+ /*background-color: #f2f2f2;*/
+ padding: 20px;
+ width: 100%;
+ height: auto;
+}
+
+.main h2 {
+ margin-bottom: 20px;
+}
+
+.row {
+ margin-bottom: 10px;
+}
+
+/* Clear floats after the columns */
+.row::after {
+ content: "";
+ display: table;
+ clear: both;
+}
+
+.align-checkbox {
+ display: flex;
+ align-items: center;
+}
+
+input[type=checkbox] {
+ margin-right: 10px;
+}
+
+button,
+input[type=submit] {
+ /*background-color: red;*/
+ background-color: #4070f4;
+ color: white;
+ padding: 12px 20px;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ min-width: 80px;
+
+}
+
+button:hover,
+input[type=submit]:hover {
+ /*background-color: rgb(235,14,14);*/
+ background-color: #2359ee;
+}
+
+input[type=text],
+input[type=file] {
+ width: 40%;
+ padding: 12px;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ margin-top: 12px;
+}
+
+input[type=file] {
+ padding: 0;
+}
+
+.col-25 {
+ float: left;
+ width: 25%;
+ margin-top: 6px;
+}
+
+.col-75 {
+ float: left;
+ width: 75%;
+ margin-top: 6px;
+}
+
+/* Media queries */
+@media screen and (max-width: 600px) {
+ button,
+ input[type=submit],
+ .col-25,
+ .col-75 {
+ width: 100%;
+ margin-top: 0;
+ }
+
+ input[type=text],
+ input[type=file] {
+ width: 100%;
+ }
+}
+
+
+/* styling of table */
+.data-table {
+ width: 100%;
+ border-collapse: collapse;
+ margin-bottom: 20px;
+ font-size: 1em;
+ text-align: left;
+}
+
+.data-table thead {
+ background-color: #f2f2f2;
+}
+
+.data-table th,
+.data-table td {
+ padding: 12px 15px;
+ border: 1px solid #ddd;
+}
+
+.data-table tbody tr:nth-child(even) {
+ background-color: #f9f9f9;
+}
+
+.data-table tbody tr:hover {
+ background-color: #f1f1f1;
+}
+
+#table-container-inner{
+ overflow-x: scroll;
+ white-space: nowrap; /* To ensure the content stays on one line for scrolling */
+ width: 100%; /* możesz dostosować */
+ max-width: 2000px;
+}
+
+/* === spcific styles === ------------------------------------------*/
+
+
+
+
+/* === error ===*/
+
+
+
+
+
+
+/* === popout message === */
+
+/** message */
+.overlayPopout {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0, 0, 0, 0.5);
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ z-index: 9999;
+}
+
+/** popout styles */
+.popout {
+ background-color: #fff;
+ padding: 10px;
+ max-width: 400px;
+ width: 80%;
+ border-radius: 15px;
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
+ text-align: center;
+ position: relative;
+ z-index: 1000;
+}
+
+/** Styles for button */
+.popout .close-btn {
+ position: absolute;
+ top: -1px;
+ right: 7px; /* can be adjusted */
+ cursor: pointer;
+ font-size: 20px;
+ color: #333;
+}
+
+.popout p {
+ margin: 0;
+ padding: 10px 0;
+ line-height: 1.5;
+}
+
+/** hide at the beggining */
+.hidden {
+ display: none;
+}
+
+
+/* === color buttons === */
+.custom-button {
+ display: inline-block;
+ width: 70px;
+ padding: 10px;
+ margin: 10px 0;
+ color: #fff;
+ text-align: center;
+ text-decoration: none;
+ border: none;
+ cursor: pointer;
+ border-radius: 5px;
+ font-size: 15px;
+ font-family: inherit;
+}
+
+.blue{
+ background-color: #4070f4;
+}
+
+.green{
+ background-color: green;
+}
+
+.orange{
+ background-color: orange;
+}
+
+.red{
+ background-color: red;
+}
+
+.blue:hover{
+ background-color: #3056c6;
+}
+
+.green:hover{
+ background-color: #006400;
+}
+
+.orange:hover{
+ background-color: #cc8400;
+}
+
+.red:hover{
+ background-color: #b30000;
+}
diff --git a/admin/JS/index.js b/admin/JS/index.js
new file mode 100644
index 0000000..f7d7bad
--- /dev/null
+++ b/admin/JS/index.js
@@ -0,0 +1,42 @@
+
+// -- SIDEBAR --
+document.addEventListener("DOMContentLoaded", function() {
+ const navBar = document.querySelector("nav"),
+ menuBtns = document.querySelectorAll(".menu-icon"),
+ overlay = document.querySelector(".overlay")
+ optionBtns = document.querySelectorAll(".list")
+
+
+ menuBtns.forEach(menuBtn => {
+ menuBtn.addEventListener("click", () => {
+ navBar.classList.toggle("open")
+ })
+ })
+
+ optionBtns.forEach(optBtn => {
+ optBtn.addEventListener("click", () => {
+ navBar.classList.remove("open")
+ })
+ })
+
+ overlay.addEventListener("click", () => {
+ navBar.classList.remove("open");
+ })
+});
+
+
+/*mesage handler*/
+document.addEventListener("DOMContentLoaded", function() {
+
+ // Zamknij popout po kliknięciu w X
+ document.getElementById('close-btn')?.addEventListener('click', function() {
+ document.getElementById('overlay').classList.add('hidden');
+ });
+
+ // Zamknij popout po kliknięciu poza nim
+ document.getElementById('overlay')?.addEventListener('click', function(event) {
+ if (event.target.id === 'overlay') {
+ document.getElementById('overlay').classList.add('hidden');
+ }
+ });
+});
\ No newline at end of file
diff --git a/admin/dashboard.alg.php b/admin/algo/dashboard.alg.php
similarity index 85%
rename from admin/dashboard.alg.php
rename to admin/algo/dashboard.alg.php
index 8588ba8..62ab4d6 100644
--- a/admin/dashboard.alg.php
+++ b/admin/algo/dashboard.alg.php
@@ -4,12 +4,12 @@
if(!isset ($_SESSION['adminLoged']))
{
- header('Location:panel.login.php');
+ header('Location: ../panel.login.php');
exit();
}
-function dasboard_data() {
+function dashboard_data() {
echo'
diff --git a/admin/algo/edit.alg.php b/admin/algo/edit.alg.php
new file mode 100644
index 0000000..051949d
--- /dev/null
+++ b/admin/algo/edit.alg.php
@@ -0,0 +1,21 @@
+ 1048576) {
+ $_SESSION['message'] = 'File too large (max 1MB).';
+ header('Location: ../panel.php?window=add-article');
+ exit();
+ }
+
+ $title = mysqli_real_escape_string($conn, $_POST['title']);
+ $textUpload = file_get_contents($_FILES['textUpload']['tmp_name']);
+ $photo = $_FILES['photoUpload'];
+
+ if ($conn->connect_errno != 0) {
+ $_SESSION['message'] = 'db connection fail.';
+ header('Location: ../panel.php?window=add-article');
+ #echo "Error: " . $conn->connect_error;
+ #throw new Exception(mysqli_connect_errno());
+ } else {
+
+ $sql = "SELECT * FROM articles WHERE title = '$title'";
+
+ if($result = $conn->query($sql)) {
+ $num = $result->num_rows;
+
+ if($num != 0) {
+ $_SESSION['message'] = 'Article with this title already exist.';
+ header('Location: ../panel.php?window=add-article');
+ } else {
+
+ $pathinfo = pathinfo($_FILES["photoUpload"]["name"]);
+
+ $base = $pathinfo["filename"];
+
+ $base = preg_replace("/[^\w-]/", "_", $base);
+
+ $filename = $base . "." . $pathinfo["extension"];
+
+ $destination = "/Applications/XAMPP/xamppfiles/htdocs/server/panel_new/articles_photos/" . $filename;
+
+ // Add a numeric suffix if the file already exists
+ $i = 1;
+
+ while (file_exists($destination)) {
+
+ $filename = $base . "($i)." . $pathinfo["extension"];
+ //$destination = "/Applications/XAMPP/xamppfiles/htdocs/serwer/panel/articles_photos/" . $filename;
+ $destination = "/Applications/XAMPP/xamppfiles/htdocs/server/panel_new/articles_photos/" . $filename;
+
+ $i++;
+ }
+
+ if ( ! move_uploaded_file($_FILES["photoUpload"]["tmp_name"], $destination)) {
+
+ echo $destination. '
';
+ $_SESSION['message'] = "Can't move uploaded file.";
+ header('Location: ../panel.php?window=add-article');
+ }
+
+ $target_file = 'articles_photos/'.$filename;
+
+ $sql_insert = $sql_insert = "INSERT INTO articles (title, text, photo_path) VALUES (?, ?, ?)";
+ $stmt_insert = $conn->prepare($sql_insert);
+ $stmt_insert->bind_param('sss', $title, $textUpload, $target_file);
+
+ if ($stmt_insert->execute()) {
+
+ $_SESSION['message'] = 'Article was succesfully addes to db.';
+ header('Location: ../panel.php?window=add-article');
+ } else {
+ $_SESSION['message'] = 'Error during adding data to db.';
+ header('Location: ../panel.php?window=add-article');
+ }
+
+ $stmt_insert->close();
+
+ #$_SESSION['message'] = 'File uploaded successfully.';
+ }
+
+ } else {
+ $_SESSION['message'] = 'Error occur during checking title.';
+ header('Location: ../panel.php?window=add-article');
+ #throw new Exception($conn->error);
+ }
+ $conn->close();
+ exit();
+ }
+}
+
+exit();
\ No newline at end of file
diff --git a/admin/password.alg.php b/admin/algo/password.alg.php
similarity index 77%
rename from admin/password.alg.php
rename to admin/algo/password.alg.php
index dd6966d..ed16b69 100644
--- a/admin/password.alg.php
+++ b/admin/algo/password.alg.php
@@ -4,13 +4,12 @@
if(!isset ($_SESSION['adminLoged']))
{
- header('Location:panel.login.php');
+ header('Location: ../panel.login.php');
exit();
}
-
//additional files
-require_once 'panel.connect.php';
+require '../panel.connect.php';
$conn = @new mysqli($host, $db_user, $db_password, $db_name);
@@ -22,7 +21,7 @@
if ($conn->connect_errno!=0) {
$_SESSION['message'] = 'connection to db fail';
#echo 'Error: '.$conn->connect_error;
- header('Location:panle.php');
+ header('Location: ../panel.php?window=settings');
exit();
}else{
@@ -48,35 +47,35 @@
if ($conn->query($sql_update) === TRUE) {
$_SESSION['message'] = 'Password changed successfully.';
- header('Location: panel.php');
+ header('Location: ../panel.php?window=settings');
} else {
$_SESSION['message'] = 'Error: something went wrong during updating password';
#echo $conn->error;
- header('Location: panel.phps');
+ header('Location: ../panel.php?window=settings');
}
} else {
$_SESSION['message'] = 'Old password is wrong';
- header('Location:panel.php');
+ header('Location: ../panel.php?window=settings');
}
} else {
$_SESSION['message'] = 'more rows found than needed';
- header('Location: panel.phps');
+ header('Location: ../panel.php?window=settings');
}
}
$conn->close();
exit();
}
} else {
- $_SESSION['message'] = 'new password different than one writen again';
- header('Location:panel.php');
+ $_SESSION['message'] = 'new password different than one written again ';
+ header('Location: ../panel.php?window=settings');
exit();
}
} else {
$_SESSION['message'] = 'POST table doesnt have all data';
- header('Location:panel.php');
+ header('Location: panel.php?window=settings');
exit();
}
diff --git a/admin/service_status.alg.php b/admin/algo/service_status.alg.php
similarity index 77%
rename from admin/service_status.alg.php
rename to admin/algo/service_status.alg.php
index a698443..40e8b55 100644
--- a/admin/service_status.alg.php
+++ b/admin/algo/service_status.alg.php
@@ -4,13 +4,12 @@
if(!isset ($_SESSION['adminLoged']))
{
- header('Location:panel.login.php');
+ header('Location: ../panel.login.php');
exit();
}
//additional files
-require_once 'panel.connect.php';
-
+require '../panel.connect.php';
$conn = @new mysqli($host, $db_user, $db_password, $db_name);
@@ -20,7 +19,7 @@
if ($conn->connect_errno!=0) {
$_SESSION['message'] = 'connection do db fail';
#echo "Error: ".$conn->connect_error;
- header('Location: panel.php');
+ header('Location: ../panel.php?window=service-break');
exit();
}else{
@@ -45,16 +44,16 @@
if ($conn->query($sql_update) === TRUE) {
$_SESSION['message'] = 'Service status value changed successfully';
- header('Location: panel.php');
+ header('Location: ../panel.php?window=service-break');
}else{
$_SESSION['message'] = 'Error: something went wrong during updating status';
#echo $conn->error;
- header('Location: panel.php');
+ header('Location: ../panel.php?window=service-break');
}
}else{
$_SESSION['message'] = 'more rows found than needed';
- header('Location: panel.php');
+ header('Location: ../panel.php?window=service-break');
}
}
$conn->close();
@@ -62,7 +61,7 @@
}
}else{
$_SESSION['message'] = 'something went wrong, try again';
- header('Location: panel.php');
+ header('Location: ../panel.php?window=service-break');
exit();
}
diff --git a/admin/all_articles.alg.php b/admin/all_articles.alg.php
index 8c3c582..c6f4266 100644
--- a/admin/all_articles.alg.php
+++ b/admin/all_articles.alg.php
@@ -9,50 +9,64 @@
function all() {
-//additional files
-require 'panel.connect.php';
-
- //$conn = @new mysqli($host, $db_user, $db_password, $db_name);
-
- #error_reporting(E_ALL);
- #ini_set('display_errors', 1);
-
-$conn = @new mysqli($host, $db_user, $db_password, $db_name);
-
-if ($conn->connect_errno) {
- $_SESSION['message'] = 'connection to db fail';
- #echo "Error: " . $conn->connect_error;
- header('Location:panel.php');
- exit();
-} else {
- // Zaktualizowane zapytanie, które pobiera dodatkowe informacje
- $sql = "SELECT * FROM articles";
- $result = $conn->query($sql);
-
- if ($result->num_rows > 0) {
- echo '
';
- echo '| ID | Title | Date of Published | Content | Image Path | View |
';
- echo '';
- // Pętla po wynikach
- while ($row = $result->fetch_assoc()) {
- echo '';
- echo '| ' . $row['ID'] . ' | ';
- echo '' . $row['title'] . ' | ';
- echo '' . $row['date_of_publish'] . ' | ';
- echo '' . substr($row['text'], 0, 50) . '... | '; // Skrócona treść
- echo '' . $row['photo_path'] . ' | ';
- echo 'Link | ';
- echo '
';
- }
- echo '';
- echo '
';
+ //additional files
+ require 'panel.connect.php';
+
+ $conn = @new mysqli($host, $db_user, $db_password, $db_name);
+
+ if ($conn->connect_errno) {
+ $_SESSION['message'] = 'connection to db fail';
+ #echo "Error: " . $conn->connect_error;
+ header('Location: panel.php?window=all-articles');
+ exit();
} else {
- $_SESSION['message'] = 'no data found';
- header('Location:panel.php');
+ $sql = "SELECT * FROM articles";
+ $result = $conn->query($sql);
- }
+ if ($result->num_rows > 0) {
+ echo '
';
+ echo '| ID | Title | Date of Published | Content | Image Path | View | Edit |
';
+ echo '';
- $conn->close();
-}
+ while ($row = $result->fetch_assoc()) {
+ echo '';
+ echo '| ' . $row['ID'] . ' | ';
+ echo '' . $row['title'] . ' | ';
+ echo '' . $row['date_of_publish'] . ' | ';
+ echo '' . substr($row['text'], 0, 50) . '... | ';
+ echo '' . $row['photo_path'] . ' | ';
+ echo 'View | ';
+ echo 'Edit | ';
+ echo '
';
+ }
+ echo '';
+ echo '
';
+ } else {
+ echo '
';
+ echo '| ID | Title | Date of Published | Content | Image Path | View | Edit |
';
+ echo '';
+
+ $info = 'No data';
+
+ echo '';
+ echo '| ' . $info . ' | ';
+ echo '' . $info . ' | ';
+ echo '' . $info . ' | ';
+ echo '' . $info . ' | ';
+ echo '' . $info . ' | ';
+ echo '' . $info . ' | ';
+ echo '' . $info . ' | ';
+ echo '
';
+
+ echo '';
+ echo '
';
+
+ $_SESSION['message'] = 'No data found. Database empty.';
+ }
+
+ $conn->close();
+ }
}
+?>
+
diff --git a/admin/index.js b/admin/index.js
deleted file mode 100644
index 155ec7e..0000000
--- a/admin/index.js
+++ /dev/null
@@ -1,89 +0,0 @@
-
-// -- SIDEBAR --
-document.addEventListener("DOMContentLoaded", function() {
- const navBar = document.querySelector("nav"),
- menuBtns = document.querySelectorAll(".menu-icon"),
- overlay = document.querySelector(".overlay")
- optionBtns = document.querySelectorAll(".list")
-
-
- menuBtns.forEach(menuBtn => {
- menuBtn.addEventListener("click", () => {
- navBar.classList.toggle("open")
- })
- })
-
- optionBtns.forEach(optBtn => {
- optBtn.addEventListener("click", () => {
- navBar.classList.remove("open")
- })
- })
-
- overlay.addEventListener("click", () => {
- navBar.classList.remove("open");
- })
-});
-
-document.addEventListener("DOMContentLoaded", function() {
-
- // Funkcja do obsługi kliknięcia w przycisk
- function handleButtonClick(sectionId) {
- // Pobierz wszystkie sekcje
- const sections = document.querySelectorAll('.section');
-
- // Ukryj wszystkie sekcje
- sections.forEach(section => section.classList.remove('visible'));
-
- // Pokaż wybraną sekcję
- document.getElementById(sectionId).classList.add('visible');
-
- }
-
- // Dodaj event listenery do przycisków
- document.getElementById("allBtn").addEventListener('click', function() {
- handleButtonClick('allSection');
- });
- document.getElementById("section1Btn").addEventListener('click', function() {
- handleButtonClick('section1');
- });
- document.getElementById("section2Btn").addEventListener('click', function() {
- handleButtonClick('section2');
- });
- document.getElementById("section3Btn").addEventListener('click', function() {
- handleButtonClick('section3');
- });
- document.getElementById("section4Btn").addEventListener('click', function() {
- handleButtonClick('section4');
- });
-
-});
-
-/*
-document.addEventListener("DOMContentLoaded", function() {
- const smallMenuBtn = document.querySelectorAll(""),
-
- smallMenuBtns.forEach(smallMenuBtn => {
- smallMenuBtn.addEventListener("click", () => {
- .classList.toggle("visible")
- })
- })
-
-})
-
-*/
-
-/*mesage handler*/
-document.addEventListener("DOMContentLoaded", function() {
-
- // Zamknij popout po kliknięciu w X
- document.getElementById('close-btn')?.addEventListener('click', function() {
- document.getElementById('overlay').classList.add('hidden');
- });
-
- // Zamknij popout po kliknięciu poza nim
- document.getElementById('overlay')?.addEventListener('click', function(event) {
- if (event.target.id === 'overlay') {
- document.getElementById('overlay').classList.add('hidden');
- }
- });
-});
\ No newline at end of file
diff --git a/admin/functions.php b/admin/old/functions.php
similarity index 95%
rename from admin/functions.php
rename to admin/old/functions.php
index 8db997f..6dc1157 100644
--- a/admin/functions.php
+++ b/admin/old/functions.php
@@ -1,8 +1,9 @@
-
@@ -32,7 +33,7 @@ function dashboard() {
@@ -103,7 +104,7 @@ function allArticles() {
include 'all_articles.alg.php';
- all();
+ //all();
?>
@@ -185,4 +186,6 @@ function settings() {
connect_errno != 0) {
$_SESSION['message'] = 'db connection fail.';
@@ -84,43 +84,45 @@
} else {
$sql = "SELECT * FROM articles WHERE title = '$title'";
- echo '4 ';
+ //echo '4 ';
if($result = $conn->query($sql)) {
$num = $result->num_rows;
- echo '5 ';
+ //echo '5 ';
if($num != 0) {
$_SESSION['message'] = 'Article with this title already exist.';
header('Location: panel.php');
} else {
- echo '6 ';
+ //echo '6 ';
$pathinfo = pathinfo($_FILES["photoUpload"]["name"]);
$base = $pathinfo["filename"];
$base = preg_replace("/[^\w-]/", "_", $base);
- echo '7 ';
+ //echo '7 ';
$filename = $base . "." . $pathinfo["extension"];
- $destination = "/Applications/XAMPP/xamppfiles/htdocs/serwer/panel/articles_photos/" . $filename;
- echo '8 ';
+ //$destination = "/Applications/XAMPP/xamppfiles/htdocs/serwer/panel/articles_photos/" . $filename; //old mac
+ $destination = "/Applications/XAMPP/xamppfiles/htdocs/server/panel_new/articles_photos/" . $filename; // new mac
+ //echo '8 ';
// Add a numeric suffix if the file already exists
$i = 1;
while (file_exists($destination)) {
- echo '9 ';
+ //echo '9 ';
$filename = $base . "($i)." . $pathinfo["extension"];
- $destination = "/Applications/XAMPP/xamppfiles/htdocs/serwer/panel/articles_photos/" . $filename;
+ //$destination = "/Applications/XAMPP/xamppfiles/htdocs/serwer/panel/articles_photos/" . $filename; //old
+ $destination = "/Applications/XAMPP/xamppfiles/htdocs/server/panel_new/articles_photos/" . $filename; // new
$i++;
}
- echo '10 ';
+ //echo '10 ';
if ( ! move_uploaded_file($_FILES["photoUpload"]["tmp_name"], $destination)) {
echo $destination. '
';
$_SESSION['message'] = "Can't move uploaded file.";
header('Location: panel.php');
}
- echo '11 ';
+ //echo '11 ';
//echo $destination;
$target_file = 'articles_photos/'.$filename;
@@ -130,19 +132,19 @@
$stmt_insert = $conn->prepare($sql_insert);
$stmt_insert->bind_param('sss', $title, $textUpload, $target_file);
- echo '12 ';
+ //echo '12 ';
if ($stmt_insert->execute()) {
- echo '13.1 ';
+ //echo '13.1 ';
$_SESSION['message'] = 'Article was succesfully addes to db.';
header('Location: panel.php');
} else {
$_SESSION['message'] = 'Error during adding data to db.';
header('Location: panel.php');
#echo "Błąd podczas dodawania artykułu: " . $conn->error;
- echo '13.2 ';
+ //echo '13.2 ';
}
- echo '14 ';
+ //echo '14 ';
$stmt_insert->close();
#$_SESSION['message'] = 'File uploaded successfully.';
@@ -151,7 +153,7 @@
} else {
$_SESSION['message'] = 'Error occur during checking title.';
- header('Location: panel.php');
+ header('Location: panel.php?window=add-article');
#throw new Exception($conn->error);
}
$conn->close();
diff --git a/admin/panel.login.css b/admin/panel.login.css
index ca72540..64e72ad 100644
--- a/admin/panel.login.css
+++ b/admin/panel.login.css
@@ -1,8 +1,6 @@
body{
- /*background-color: lightslategray;*/
background-color: #fff;
- /*background-color: #e3f2fd;*/
height: 100%;
margin: 0;
padding: 0;
@@ -18,11 +16,9 @@ main{
}
#loginBox{
- width: 340px; /*380px*/
- height: 290px; /*280px*/
- border-radius: 5px; /* 8px*/
- /*background-color: lightgrey;*/
- /*background-color: #fff;*/
+ width: 320px;
+ height: 290px;
+ border-radius: 5px;
position: absolute;
top: 45%;
left: 50%;
@@ -44,28 +40,25 @@ main{
}
input[type="text"], input[type="password"] {
- width: 200px; /*180px*/
+ width: 200px;
padding: 10px;
margin: 5px 0;
box-sizing: border-box;
- border-radius: 5px; /*8px*/
+ border-radius: 5px;
border: none;
font-size: 13px;
border: 1px solid #333;
}
input[type="submit"] {
- width: 200px; /*180px*/
+ width: 200px;
padding: 10px;
margin: 10px 0;
- /*background-color: #4CAF50;/*
- /*background-color: red;*/
background-color: #4070f4;;
- color: white;
- /*color: #333;*/
+ color: #fff;
border: none;
cursor: pointer;
- border-radius: 5px; /*8px*/
- font-size: 14px;
+ border-radius: 5px;
+ font-size: 16px;
}
footer{
@@ -73,12 +66,11 @@ footer{
bottom: 0;
width: 100%;
height: 30px;
- background-color: #f1f1f1;
text-align: center;
line-height: 30px;
- background-color: lightgray;
+ background-color: #4070f4;
+ color: #fff;
font-size: 22px;
-
}
@@ -149,7 +141,7 @@ footer{
}
}
-@media (max-width: 260px) OR (max-height: 460px){
+@media (max-width: 300px) OR (max-height: 460px){
main{
display: none;
}
diff --git a/admin/panel.login.php b/admin/panel.login.php
index 7dcfb99..51ae66e 100644
--- a/admin/panel.login.php
+++ b/admin/panel.login.php
@@ -3,21 +3,18 @@
session_start();
-
-if((isset($_SESSION['adminLoged'])) && ($_SESSION['aminLoged'] == true))
+if((isset($_SESSION['adminLoged'])) && ($_SESSION['adminLoged'] == true)) // think over
{
- //unset($_SESSION['adminLoged']);
header('Location: panel.php');
exit();
-
- //jesli nie chcemy by zosrtały wykonane następne instrukcje w skrypcie php
- //znajdujące sie poniej instrukcji header naley uzyć exit();
- //nastąpi natychmiastowe przekierowanie
- // nie kończymy imprzy, wychodzimy po angielsku
+ // nie kończymy imprezy, wychodzimy po angielsku
}
-
+// cache control
+header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
+header("Cache-Control: post-check=0, pre-check=0", false);
+header("Pragma: no-cache");
?>
diff --git a/admin/panel.logout.alg.php b/admin/panel.logout.alg.php
index 04f5e10..75017ea 100644
--- a/admin/panel.logout.alg.php
+++ b/admin/panel.logout.alg.php
@@ -2,6 +2,8 @@
session_start();
+ $_SESSION['adminLoged'] = false; // i make sure it has value different from true
+
session_unset(); //session_destroy();
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
@@ -9,5 +11,5 @@
header('Pragma: no-cache');
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
- header('Location:panel.login.php');//panel.logout.out.php
+ header('Location:panel.login.php'); //panel.logout.out.php
exit();
diff --git a/admin/panel.php b/admin/panel.php
index 9c02241..dcbbe15 100644
--- a/admin/panel.php
+++ b/admin/panel.php
@@ -3,25 +3,26 @@
1800)) {
- // Sesja wygasła - usuń dane sesji
- session_unset(); // Usuń wszystkie zmienne sesji
- session_destroy(); // Zniszcz sesję
+ // Session expired - delete session data
+ session_unset(); // Delete all session variables
+ session_destroy(); // Destroy session
}
-$_SESSION['LAST_ACTIVITY'] = time(); // Aktualizacja czasu ostatniej aktywności
+$_SESSION['LAST_ACTIVITY'] = time(); // Last Activity Time Update
//additional files
require_once 'panel.connect.php';
-include_once 'functions.php';
+include 'window_functions.php';
?>
@@ -45,8 +46,8 @@
-
-
+
+
@@ -76,11 +77,10 @@
-
-
+ }else{ // if new widows added, there must be added new if statements added as well
+
+ if($_GET["window"] == "all-articles"){
-
-
+
+
+ }elseif($_GET["window"] == "edit-article"){
+
+ editArticle();
+
+ }elseif($_GET["window"] == "service-break"){
-
-
+ }elseif($_GET["window"] == "settings"){
-
-
+
+ }else{
+
+ error();
+
+ }
+ }
+ ?>
@@ -214,7 +223,7 @@
?>
-
+