Reddot - is not a commercial educational project with:
Reddot - is a web server and website with CMS on it. Features:
- User registrations;
- User login;
- User logout;
- Deleting an account by the user;
- Writing posts;
- Editing posts;
- Deleting posts;
Each user can view posts of other users, but can only manage their own account and their posts.
The project implemented:
- Thread-safe logger with different logging levels;
- Support configuration from file;
- Calculation of hashes;
- Working with the file system;
- Server supporting HTTP protocol and secure connection using HTTPS. A certificate has been generated and signed;
- A database and tables were created in the MySQL. The tables are filled with initial data;
- Working with the MySQL forming queries, obtaining results, error handling;
- Web pages written using HTML and CSS, placed placeholders;
- CMS responsible for query parsing, business logic, and generation and delivery of content (web pages);
- Support for user sessions;
- Filters for web security and protection against web attacks;
The project uses design patterns: Singleton
, Factory
, Prototype
, Strategy
.
Index page for guest:
Registration page:
Login page:
Index page for user:
Account page:
Post creation page:
Post view page:
Post editing page:
Stopping a service:
sudo service mysql stop
Create a file:
/home/<username>/mysql-init
Write in a file:
ALTER USER 'root'@'127.0.0.1' IDENTIFIED BY '<NewPassword>';
Use a file to init MySQL:
sudo mysqld --init-file=/home/<username>/mysql-init &
Starting a service:
sudo service mysql start
Login into MySQL:
sudo mysql -u root -p
Execute queries in MySQL:
CREATE USER 'reddot'@'%' IDENTIFIED BY 'reddot';
GRANT ALL PRIVILEGES ON reddot.* TO 'reddot'@'%';
FLUSH PRIVILEGES;
Execute queries in MySQL:
CREATE DATABASE IF NOT EXISTS reddot;
USE reddot;
CREATE TABLE roles (id INT AUTO_INCREMENT PRIMARY KEY, description VARCHAR(32));
CREATE TABLE users (login VARCHAR(64) PRIMARY KEY, password VARCHAR(64), role_id INT, FOREIGN KEY (role_id) REFERENCES roles(id));
CREATE TABLE posts (id INT AUTO_INCREMENT PRIMARY KEY, login VARCHAR(64), caption VARCHAR(255), body TEXT, FOREIGN KEY (login) REFERENCES users(login));
Execute queries in MySQL:
INSERT INTO roles (description) VALUES ('Administrator');
INSERT INTO roles (description) VALUES ('User');
INSERT INTO users (login, password, role_id) VALUES ('admin', MD5('admin'), 1);
INSERT INTO posts (login, caption, body) VALUES ('admin', 'Welcome post', 'Welcome to Reddot!');
Stopping a service:
sudo service mysql stop
In the settings file, comment out the "bind" line:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Add firewall rule:
sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
Starting a service:
sudo service mysql start
Important: the resources folder must be in the same directory where the executable file is located.
Updating and installing dependencies:
sudo apt-get update && sudo apt install g++ cmake build-essential libgtest-dev libboost-program-options-dev libssl-dev ca-certificates libpoco-dev libpoconetssl80 libmysqlclient-dev -y
Generate cmake files:
cd Reddot
mkdir build && cd build
cmake ..
Build debug:
cmake --build .
Build release:
cmake --build . --config Release
Build deb-package:
cmake --build . --target package
Installing dependencies:
vcpkg install gtest boost-program-options openssl libmysql poco poco[netssl] --recurse poco[mysql] --recurse poco:x64-windows-release
vcpkg integrate install
Generate cmake files:
cd Reddot
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE="path/to/vcpkg/scripts/buildsystems/vcpkg.cmake"
Build debug:
cmake --build .
Build release:
cmake --build . --config Release
Set parameters in config file config.ini
:
- web_root_path - path to web-pages;
- server_port - port for server;
- db_login - login to MySQL;
- db_password - password to MySQL;
- db_server - host MySQL;
- db_port - port MySQL;
- db_name - database name to MySQL;
Starting unit-tests:
ctest
Starting the server
Release>Reddot.exe
[08-05-2024 12:46:20] (Info) Server is running
[08-05-2024 12:46:20] (Info) Init config
[08-05-2024 12:46:20] (Info) Init CMS
[08-05-2024 12:46:20] (Info) Init DB connection
WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.
[08-05-2024 12:46:20] (Info) Init Server
[08-05-2024 12:46:20] (Info) Key file : resources/cert/reddot.key
[08-05-2024 12:46:20] (Info) Cert file : resources/cert/reddot.crt
[08-05-2024 12:46:20] (Info) Port : 4444
[08-05-2024 12:46:20] (Info) Max queued : 100
[08-05-2024 12:46:20] (Info) Max threads: 20
[08-05-2024 12:46:20] (Info) Waiting connections...