Skip to content

Commit b59a613

Browse files
Cookies for users in /public
1 parent 483762f commit b59a613

20 files changed

Lines changed: 184 additions & 108 deletions

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ The project is ready for use but is still evolving. Work is ongoing to fix bugs
1010

1111
### Added
1212
<!-- - Initial examples of added changelog entries. -->
13+
14+
`/public`
15+
1 - cookies for users, db collects data for analytics
16+
2 - tables for cookies added
17+
3 - JS folder
1318
.....
1419

1520
### Changed
1621
<!-- - Improved existing changelog entries for consistency. -->
22+
23+
`/public`
24+
1 - structure of /public fixes
1725
.....
1826

1927
### Fixed

admin/panel.connect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$host = "localhost";
44
$db_user = "root";
5-
$db_password ="";
5+
$db_password ="root";
66
$db_name = "blog";
77

88

database_SQL/blog_DB_data.sql

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
21
START TRANSACTION;
3-
SET time_zone = "+00:00";
4-
5-
USE `blog`;
6-
7-
--
8-
-- Inserting data into table `admin`
9-
--
102

113
INSERT INTO `admin` (`id`, `login`, `password`) VALUES
12-
(1, 'admin', '$2y$10$L9fQlnPTTuYkNhLnXh68..F8R.bJdLaAJBJjXU8RjhiHUHFVVJyCe');
4+
(1, 'admin', '$2y$10$w9GkWVGXxSTjw4A9QyjasuqyeJyUPp2JlWYnFGFEen7e2..YUXxNC');
135

14-
--
15-
-- Inserting data into table `service`
16-
--
6+
-- --------------------------------------------------------
177

188
INSERT INTO `service` (`id`, `service_status`) VALUES
19-
(1, 1);
20-
9+
(1, 0);
2110

2211
COMMIT;

database_SQL/blog_DB_structure.sql

Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,64 @@
1+
-- Databse 'blog': structure
12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
23
START TRANSACTION;
34
SET time_zone = "+00:00";
45

5-
CREATE DATABASE IF NOT EXISTS `blog`;
6-
USE `blog`;
7-
8-
/*!40101 SET NAMES utf8mb4 */;
9-
10-
--
11-
-- Table structure for table `admin`
12-
--
6+
-- --------------------------------------------------------
137

148
CREATE TABLE `admin` (
15-
`id` int(11) NOT NULL,
16-
`login` varchar(25) NOT NULL,
17-
`password` varchar(25) NOT NULL
9+
`id` int NOT NULL AUTO_INCREMENT,
10+
`login` varchar(25) COLLATE utf8mb4_general_ci NOT NULL,
11+
`password` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
12+
PRIMARY KEY (`id`)
1813
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
1914

20-
--
21-
-- Table structure for table `articles`
22-
--
15+
-- --------------------------------------------------------
2316

2417
CREATE TABLE `articles` (
25-
`ID` int(11) NOT NULL,
26-
`title` varchar(255) NOT NULL,
27-
`text` text NOT NULL,
28-
`photo_path` varchar(255) NOT NULL,
29-
`date_of_publish` timestamp NOT NULL DEFAULT current_timestamp()
18+
`ID` int NOT NULL AUTO_INCREMENT,
19+
`title` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
20+
`text` text COLLATE utf8mb4_general_ci NOT NULL,
21+
`photo_path` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
22+
`date_of_publish` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
23+
PRIMARY KEY (`ID`)
3024
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
3125

32-
--
33-
-- Table structure for table `service`
34-
--
26+
-- --------------------------------------------------------
27+
28+
CREATE TABLE `page_views_daily` (
29+
`id` int NOT NULL AUTO_INCREMENT,
30+
`page` varchar(191) NOT NULL,
31+
`visit_date` date NOT NULL DEFAULT (curdate()),
32+
`visit_count` int NOT NULL DEFAULT '1',
33+
PRIMARY KEY (`id`),
34+
UNIQUE KEY `unique_page_date` (`page`,`visit_date`)
35+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
36+
37+
-- --------------------------------------------------------
3538

3639
CREATE TABLE `service` (
37-
`id` int(11) NOT NULL,
38-
`service_status` tinyint(1) NOT NULL
40+
`id` int NOT NULL AUTO_INCREMENT,
41+
`service_status` tinyint(1) NOT NULL,
42+
PRIMARY KEY (`id`)
3943
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
4044

41-
--
42-
-- Table structure for table `settings`
43-
--
45+
-- --------------------------------------------------------
4446

4547
CREATE TABLE `settings` (
46-
`id` int(11) NOT NULL,
47-
`is_active` tinyint(1) NOT NULL
48+
`id` int NOT NULL AUTO_INCREMENT,
49+
`is_active` tinyint(1) NOT NULL,
50+
PRIMARY KEY (`id`)
4851
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
4952

50-
--
51-
-- Indexes for tables
52-
--
53-
54-
ALTER TABLE `admin`
55-
ADD PRIMARY KEY (`id`);
56-
57-
ALTER TABLE `articles`
58-
ADD PRIMARY KEY (`ID`);
59-
60-
ALTER TABLE `service`
61-
ADD PRIMARY KEY (`id`);
62-
63-
ALTER TABLE `settings`
64-
ADD PRIMARY KEY (`id`);
65-
66-
--
67-
-- AUTO_INCREMENT for tables
68-
--
69-
70-
ALTER TABLE `admin`
71-
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
72-
73-
ALTER TABLE `articles`
74-
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;
53+
-- --------------------------------------------------------
7554

76-
ALTER TABLE `settings`
77-
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
55+
CREATE TABLE `visitors` (
56+
`id` int NOT NULL AUTO_INCREMENT,
57+
`cookie_id` varchar(64) DEFAULT NULL,
58+
`visit_count` int DEFAULT '1',
59+
`first_visit` datetime DEFAULT CURRENT_TIMESTAMP,
60+
PRIMARY KEY (`id`),
61+
UNIQUE KEY `cookie_id` (`cookie_id`)
62+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
7863

7964
COMMIT;
File renamed without changes.
File renamed without changes.

public/JS/popout.js

Whitespace-only changes.

public/error.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<title>Error page</title>
77

88
<!--== CSS FILE ==-->
9-
<link rel="stylesheet" href="main.css" />
9+
<link rel="stylesheet" href="./CSS/main.css" />
1010

1111
<!--== CSS STYLES ==-->
1212
<style>
@@ -19,7 +19,10 @@
1919

2020
</style>
2121

22-
<!--== JS ==-->
22+
<!--== JS FILE ==-->
23+
<script src="./JS/popout.js"></script>
24+
25+
<!--== JS SCRIPT ==-->
2326
<script>
2427
</script>
2528
</head>
@@ -34,7 +37,7 @@ <h1><!--404-->Error page</h1>
3437

3538
<p>Something went wrong.<!--Don't worry, you didn't do anything wrong. We just couldn't find what you are looking for.--><br><br>Try to search what you have been looking for on main page:</p>
3639

37-
<a href="index.php">Link: Blog main page</a>
40+
<p>Link: <a href="index.php">Blog main page</a></p>
3841
</main>
3942

4043
</body>

public/error_404.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@
33

44
session_start();
55

6-
include_once 'functions.php';
7-
require_once 'service.alg.php';
8-
include 'connect.php';
6+
include_once './handlers/functions.php';
7+
require_once './handlers/service.alg.php';
8+
require_once './handlers/cookies.php';
99

1010
service();
1111

12+
$page = 'error_404.php';
13+
cookie($page);
14+
15+
1216
?>
1317
<html lang="en">
1418
<head>
1519
<meta charset="UTF-8">
1620
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1721
<title>404 error </title>
1822

19-
<link rel="stylesheet" href="main.css" />
20-
<link rel="stylesheet" href="single.css" />
23+
<link rel="stylesheet" href="./CSS/main.css" />
24+
<link rel="stylesheet" href="./CSS/single.css" />
25+
26+
<script src="./JS/popout.js"></script>
2127

2228
</head>
2329
<body>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
$host = "localhost";
55
$db_user = "root";
6-
$db_password ="";
6+
$db_password ="root";
77
$db_name = "blog";
88

99

0 commit comments

Comments
 (0)