From e9c12c9321e452b5c29b00ba0f297289e4df7e8c Mon Sep 17 00:00:00 2001 From: flash Date: Tue, 24 Dec 2024 10:37:16 +0100 Subject: [PATCH] Source cleanup + SQL structure --- chie.sql | 154 +++++++++++++++ include/_user.php | 6 +- layout/footer.php | 22 --- layout/header.php | 49 ----- public/hook/github.php | 26 --- public/posting.php | 4 +- public/register.php | 6 +- public/settings.php | 5 +- public/style2.css | 434 ----------------------------------------- 9 files changed, 162 insertions(+), 544 deletions(-) create mode 100644 chie.sql delete mode 100644 public/hook/github.php delete mode 100644 public/style2.css diff --git a/chie.sql b/chie.sql new file mode 100644 index 0000000..fd5430a --- /dev/null +++ b/chie.sql @@ -0,0 +1,154 @@ +-- -------------------------------------------------------- +-- Host: 127.0.0.1 +-- Server version: 10.4.18-MariaDB-1:10.4.18+maria~bionic-log - mariadb.org binary distribution +-- Server OS: debian-linux-gnu +-- HeidiSQL Version: 11.2.0.6213 +-- -------------------------------------------------------- + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET NAMES utf8 */; +/*!50503 SET NAMES utf8mb4 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + + +-- Dumping database structure for flash_forum +CREATE DATABASE IF NOT EXISTS `flash_forum` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */; +USE `flash_forum`; + +-- Dumping structure for table flash_forum.fmf_categories +CREATE TABLE IF NOT EXISTS `fmf_categories` ( + `cat_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `cat_order` smallint(6) NOT NULL DEFAULT 0, + `cat_type` tinyint(3) unsigned NOT NULL DEFAULT 0, + `cat_parent` int(10) unsigned NOT NULL DEFAULT 0, + `cat_variation` tinyint(3) unsigned NOT NULL DEFAULT 0, + `cat_created` timestamp NOT NULL DEFAULT current_timestamp(), + `cat_name` varchar(50) COLLATE utf8mb4_bin NOT NULL, + `cat_description` text COLLATE utf8mb4_bin DEFAULT NULL, + `cat_link` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, + `cat_count_topics` int(10) unsigned NOT NULL DEFAULT 0, + `cat_count_posts` int(10) unsigned NOT NULL DEFAULT 0, + `cat_last_post_id` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`cat_id`), + KEY `categories_type_key` (`cat_type`), + KEY `categories_parent_key` (`cat_parent`), + KEY `categories_order_key` (`cat_order`), + KEY `categories_last_post_foreign` (`cat_last_post_id`), + CONSTRAINT `categories_last_post_foreign` FOREIGN KEY (`cat_last_post_id`) REFERENCES `fmf_posts` (`post_id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- Data exporting was unselected. + +-- Dumping structure for table flash_forum.fmf_posts +CREATE TABLE IF NOT EXISTS `fmf_posts` ( + `post_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `topic_id` int(10) unsigned NOT NULL, + `cat_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned DEFAULT NULL, + `post_type` tinyint(3) unsigned NOT NULL DEFAULT 0, + `post_created` timestamp NOT NULL DEFAULT current_timestamp(), + `post_edited` timestamp NULL DEFAULT NULL, + `post_deleted` timestamp NULL DEFAULT NULL, + `post_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + PRIMARY KEY (`post_id`), + KEY `posts_topic_foreign` (`topic_id`), + KEY `posts_user_foreign` (`user_id`), + KEY `posts_category_foreign` (`cat_id`), + KEY `posts_created_key` (`post_created`), + KEY `posts_deleted_key` (`post_deleted`), + FULLTEXT KEY `posts_text_fulltext` (`post_text`), + CONSTRAINT `posts_category_foreign` FOREIGN KEY (`cat_id`) REFERENCES `fmf_categories` (`cat_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `posts_topic_foreign` FOREIGN KEY (`topic_id`) REFERENCES `fmf_topics` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `posts_user_foreign` FOREIGN KEY (`user_id`) REFERENCES `fmf_users` (`user_id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- Data exporting was unselected. + +-- Dumping structure for table flash_forum.fmf_sessions +CREATE TABLE IF NOT EXISTS `fmf_sessions` ( + `sess_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `sess_key` char(64) COLLATE utf8mb4_bin NOT NULL, + `sess_created` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`sess_id`), + UNIQUE KEY `sessions_key_unique` (`sess_key`), + KEY `sessions_user_foreign` (`user_id`), + KEY `sessions_created_key` (`sess_created`), + CONSTRAINT `sessions_user_foreign` FOREIGN KEY (`user_id`) REFERENCES `fmf_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- Data exporting was unselected. + +-- Dumping structure for table flash_forum.fmf_topics +CREATE TABLE IF NOT EXISTS `fmf_topics` ( + `topic_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `cat_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + `topic_created` timestamp NOT NULL DEFAULT current_timestamp(), + `topic_bumped` timestamp NULL DEFAULT NULL, + `topic_locked` timestamp NULL DEFAULT NULL, + `topic_resolved` timestamp NULL DEFAULT NULL, + `topic_confirmed` timestamp NULL DEFAULT NULL, + `topic_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `topic_count_replies` int(10) unsigned NOT NULL DEFAULT 0, + `topic_last_post_id` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`topic_id`), + KEY `topics_category_foreign` (`cat_id`), + KEY `topics_bumped_key` (`topic_bumped`), + KEY `topics_title_key` (`topic_title`), + KEY `topics_user_foreign` (`user_id`), + KEY `topic_last_post_foreign` (`topic_last_post_id`), + CONSTRAINT `topic_last_post_foreign` FOREIGN KEY (`topic_last_post_id`) REFERENCES `fmf_posts` (`post_id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `topics_category_foreign` FOREIGN KEY (`cat_id`) REFERENCES `fmf_categories` (`cat_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `topics_user_foreign` FOREIGN KEY (`user_id`) REFERENCES `fmf_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- Data exporting was unselected. + +-- Dumping structure for table flash_forum.fmf_track +CREATE TABLE IF NOT EXISTS `fmf_track` ( + `cat_id` int(10) unsigned NOT NULL, + `topic_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + `track_timestamp` timestamp NOT NULL DEFAULT current_timestamp(), + UNIQUE KEY `track_unique` (`topic_id`,`user_id`), + KEY `track_category_foreign` (`cat_id`), + KEY `track_topic_foreign` (`topic_id`), + KEY `track_user_foreign` (`user_id`), + KEY `track_timestamp_key` (`track_timestamp`), + CONSTRAINT `track_category_foreign` FOREIGN KEY (`cat_id`) REFERENCES `fmf_categories` (`cat_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `track_topic_foreign` FOREIGN KEY (`topic_id`) REFERENCES `fmf_topics` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `track_user_foreign` FOREIGN KEY (`user_id`) REFERENCES `fmf_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- Data exporting was unselected. + +-- Dumping structure for table flash_forum.fmf_users +CREATE TABLE IF NOT EXISTS `fmf_users` ( + `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_login` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `user_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `user_email_verification` char(32) COLLATE utf8mb4_bin DEFAULT NULL, + `user_password` varchar(255) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, + `user_moderator` tinyint(3) unsigned NOT NULL DEFAULT 0, + `user_created` timestamp NOT NULL DEFAULT current_timestamp(), + `user_ip_created` varbinary(16) NOT NULL, + `user_date_format` varchar(50) COLLATE utf8mb4_bin NOT NULL DEFAULT 'D Y-m-d H:i:s T', + `user_time_zone` varchar(50) COLLATE utf8mb4_bin NOT NULL DEFAULT 'UTC', + `user_flags` int(10) unsigned NOT NULL DEFAULT 0, + `user_banned` timestamp NULL DEFAULT NULL, + `user_banned_reason` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`user_id`), + UNIQUE KEY `users_login_unique` (`user_login`), + UNIQUE KEY `users_email_unique` (`user_email`), + UNIQUE KEY `users_email_verification_unique` (`user_email_verification`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- Data exporting was unselected. + +/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; +/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */; diff --git a/include/_user.php b/include/_user.php index 618b280..3d96fbf 100644 --- a/include/_user.php +++ b/include/_user.php @@ -2,7 +2,7 @@ include_once '_utils.php'; define('FMF_UF_SCROLLBEYOND', 1); -define('FMF_UF_NEWSTYLE', 2); +//define('FMF_UF_NEWSTYLE', 2); function get_user_id(string $username, string $email): int { global $pdo; @@ -217,7 +217,7 @@ function verify_password(string $pass, ?int $user = null): bool { function user_set_password(int $user, string $password): void { global $pdo; - + if($user < 1) return; @@ -231,7 +231,7 @@ function user_set_password(int $user, string $password): void { function user_set_email(int $user, string $email, bool $verified = false): ?string { global $pdo; - + if($user < 1) return null; diff --git a/layout/footer.php b/layout/footer.php index 3413c2a..66a54c5 100644 --- a/layout/footer.php +++ b/layout/footer.php @@ -1,11 +1,4 @@ - - - - diff --git a/layout/header.php b/layout/header.php index b03d2ca..437ac0b 100644 --- a/layout/header.php +++ b/layout/header.php @@ -1,8 +1,5 @@ @@ -10,41 +7,10 @@ if(user_has_flag(current_user_id(), FMF_UF_NEWSTYLE)) <?=$title ?? 'flash.moe message board';?> - - - - - - - - -
-
- -
- //flash.moe/assets/headers/mkt-044.jpg -
- -

flash.moe message board

@@ -64,19 +30,4 @@ if(user_has_flag(current_user_id(), FMF_UF_NEWSTYLE))
-
- -
-
- - - - -
- This message board will be taken offline in May 2021. Registration and posting have already been disabled.
- Musewave support has moved to a forum topic on Flashii.net. -
\ No newline at end of file diff --git a/public/hook/github.php b/public/hook/github.php deleted file mode 100644 index a899b90..0000000 --- a/public/hook/github.php +++ /dev/null @@ -1,26 +0,0 @@ - 0) { if($topicId > 0) { $topicInfo = topic_info($topicId); - + if(empty($topicInfo)) die_ex('Topic not found.', 404); diff --git a/public/register.php b/public/register.php index 9f96fa6..55f5e4b 100644 --- a/public/register.php +++ b/public/register.php @@ -1,8 +1,6 @@ 'Scroll beyond end of the page.', - FMF_UF_NEWSTYLE => 'Preview new style.', ]; $timeZones = DateTimeZone::listIdentifiers(); @@ -112,10 +111,10 @@ foreach($timeZones as $key => $timeZone) { uasort($timeZones, function($a, $b) { $diff = $a->offset <=> $b->offset; - + if($diff === 0) return strcmp($a->getName(), $b->getName()); - + return $diff; }); diff --git a/public/style2.css b/public/style2.css deleted file mode 100644 index 070feb9..0000000 --- a/public/style2.css +++ /dev/null @@ -1,434 +0,0 @@ -h1 { - color: #9DAAD9; - font-weight: bold; - font-size: 22px; - text-decoration: none; -} - -h2 { - font-weight: bold; - font-size: 22px; - text-decoration: none; - line-height: 120%; -} - -h3 { - font-size: 1.3em; - font-weight: bold; - line-height: 120%; -} - -h4 { - margin: 0; - font-size: 1.1em; - font-weight: bold; -} - -p { - font-size: 1.1em; -} - -h3 > a { - display: inline-block; - padding: 2px 5px; -} - -input[type="text"], -input[type="password"], -input[type="email"], -input[type="search"], -input[type="submit"], -input[type="reset"], -input[type="button"] { - color: #9daad9; - font-family: Tahoma, Geneva, 'Dejavu Sans', Arial, Helvetica, sans-serif; - font-size: 12px; - font-weight: 400; - padding: 2px; - border: 1px solid #9daad9; - background-color: #191E33; -} - -input[type="button"], -input[type="reset"], -input[type="submit"] { - cursor: pointer; - padding: 2px 4px; -} - -input[type="submit"] { - font-weight: 700; -} - -textarea { - background-color: #191E33; - color: #9DAAD9; - font-family: Tahoma, Geneva, 'Dejavu Sans', Arial, Helvetica, sans-serif; - font-weight: normal; - border: 1px solid #A9B8C2; - padding: 2px; - font-size: 12px; -} - -select { - color: #9DAAD9; - background-color: #191E33; - font-family: Tahoma, Geneva, 'Dejavu Sans', Arial, Helvetica, sans-serif; - font-size: 11px; - font-weight: normal; - border: 1px solid #A9B8C2; - padding: 1px; -} - -option { - padding: 0 1em 0 0; -} - -.wrapper { - margin: 0 auto; - width: 100%; - max-width: 1000px; -} -.wrapper.scrollbeyond { - padding-bottom: 100vh; -} - -.wrapper a { - color: #567194; - text-decoration: none; - transition: color .1s; -} - -.wrapper a:active { - color: #4C5A8E; - text-decoration: none; -} - -.wrapper a:hover { - color: #FFFFFF; - text-decoration: underline; -} - -.forum-category, -.topics { - border: 1px solid #000; - background-color: #191e33; - color: #cecece; - margin: 4px 0; -} -.forum-category-title, -.topics-header { - font-weight: 700; - display: flex; - align-items: center; -} -.forum-category-title-info, -.topics-header-info { - flex: 1 1 auto; - padding: 4px 5px; -} -.forum-category-board, -.topics-item { - border-top: 1px solid #000; - background-color: #1a2237; - display: flex; - align-items: center; - min-height: 40px; -} -.forum-category-board-indicator, -.topics-item-indicator, -.topics-item-indicator-closed, -.topics-item-indicator-locked { - width: 20px; - height: 20px; - line-height: 20px; - border: 1px solid #000; - flex: 0 0 auto; - margin: 5px; - background-color: #1a2237; -} -.topics-item-indicator-closed { - background-color: #0c0; - margin-left: 0; -} -.topics-item-indicator-locked { - background-color: #c00; - margin-left: 0; -} -.forum-category-board-indicator.unread, -.topics-item-indicator.unread { - background-color: #4D556A; -} -.topics-item-indicator, -.topics-item-indicator-closed, -.topics-item-indicator-locked { - width: 16px; - height: 16px; - line-height: 16px; -} -.forum-category-board-info, -.topics-item-info { - flex: 1 1 auto; -} -.forum-category-count, -.topics-item-count { - width: 60px; - text-align: center; - padding: 4px 5px; -} -.forum-category-latest, -.topics-item-author, -.topics-item-created, -.topics-item-latest { - width: 120px; - text-align: center; -} -.topics-item-created time, -.forum-category-latest time, -.topics-item-latest time { - font-size: .9em; - line-height: 1.2em; - display: inline-block; -} -.forum-category-latest-header, -.topics-item-latest-header { - padding: 4px 5px; -} -.forum-category-board-desc { - font-size: .9em; - line-height: 1.2em; -} -.topics-item-status { - display: inline-block; - margin-right: 4px; -} - -.auth-form { - max-width: 300px; - margin: 5px auto; -} -.auth-header { - padding: 5px 0; -} -.auth-field { - margin: 5px 0; - display: block; -} -.auth-field-value input { - width: 100%; -} -.auth-buttons { - text-align: center; - padding: 5px; -} -.auth-message { - text-align: center; -} -.auth-message-error { - color: #f00; -} -.forum-title { - padding: 2px 5px; -} - -.posting-header { - display: flex; - padding: 4px 0; -} -.posting-title { - flex: 1 1 auto; -} -.posting-submit { - margin-left: 4px; -} -.posting-text { - display: block; - width: 100%; - min-width: 100%; - max-width: 100%; - min-height: 500px; -} -.posting-message { - padding: 0 3px; -} -.posting-message-error { - color: #f00; -} - -.createtopicbtn, -.topic-btns a { - display: inline-block; - color: #fff !important; - text-decoration: none !important; - font-size: 12px; - font-weight: 400; - padding: 5px 10px; - background-color: #393939; - background-image: linear-gradient(0deg, #1118 0%, #2228 50%, #3338 50%, #5558 100%); - border-radius: 5px; - overflow: hidden; - cursor: pointer; - filter: drop-shadow(0 1px 5px #000); - margin: 5px 0; - margin-right: 10px; -} - -.search-form { - display: flex; -} -.search-input { - flex: 1 1 auto; -} -.search-submit { - margin-left: 4px; -} - -.post { - display: flex; - border: 1px solid #000; - background-color: #191e33; - color: #cecece; - margin: 2px 0; -} -.post-details { - flex: 0 0 auto; - width: 120px; - display: flex; - flex-direction: column; - align-items: center; - border: 0 solid #000; - border-right-width: 1px; -} -.post-permalink-wrap { - text-align: center; - font-size: .9em; - line-height: 1.4em; -} -.post-username { - font-size: 1.2em; - line-height: 1.5em; -} -.post-details * { - margin: 1px 0; -} -/*@media(max-width: 600px) {*/ - .post { - flex-direction: column; - } - .post-details { - border-right-width: 0; - border-bottom-width: 1px; - width: 100%; - flex-direction: row; - } - .post-avatar { - width: 40px; - height: 40px; - order: 1; - margin: 5px; - } - .post-username { - order: 2; - padding: 10px; - } - .post-permalink-wrap { - order: 3; - flex: 1 1 auto; - text-align: right !important; - } - .post-permalink { - padding: 10px; - } -/*}*/ -.post-text { - flex: 1 1 auto; - background-color: #1a2237; - min-height: 160px; - padding: 2px 5px; - display: flex; - flex-direction: column; -} -.post-text-inner { - flex: 1 1 auto; - padding: 3px 0; - word-wrap: normal; - word-break: break-word; -} -.post-footer { - display: flex; - flex: 0 0 auto; - font-size: .9em; -} -.post-edited { - flex: 1 1 auto; - font-style: italic; -} -.post-options { - flex: 0 0 auto; -} -.post-options a { - margin: 0 5px; -} -.post-deleted .post-text { - min-height: 0; -} - -.setting { - margin: 10px 0; -} -.setting-head h3 { - line-height: 1.5em; -} -.setting-value input[type="text"], -.setting-value input[type="password"], -.setting-value input[type="email"], -.setting-value select { - min-width: 400px; - margin: 1px 0; -} -.settings-message { - padding: 0 3px; -} -.settings-message-error { - color: #f00; -} -.settings-option { - margin: 2px 0; - padding: 0 4px; - display: block; -} - -.event { - display: block; - border: 1px solid #000; - background-color: #191e33; - color: #cecece; - margin: 2px 0; -} -.event-msg { - margin: 4px; - display: flex; -} -.event-msg img { - vertical-align: bottom; -} -.event-msg time { - font-size: .9em; - margin: 0 4px; -} -.event-msg-text { - flex: 1 1 auto; - margin: 0 4px; -} - -.notice { - display: block; - border: 1px solid #000; - background-color: #1a2237; - color: #cecece; - margin: 2px 0; - padding: 4px; -} - -.header-search { -}