├── .idea ├── .gitignore ├── php.xml ├── vcs.xml ├── sqldialects.xml ├── modules.xml ├── MessageBoard.iml └── dataSources.xml ├── README.md ├── LICENSE ├── submit.php ├── js └── index.js ├── message.sql ├── .gitignore └── index.php /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 数据源本地存储已忽略文件 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # 基于编辑器的 HTTP 客户端请求 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /.idea/php.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/sqldialects.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/MessageBoard.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MessageBoard 2 | A simple message board with PHP and MDUI 3 | 一个简单的PHP+MDUI留言板 4 | 5 | 首先请导入**message.sql**至数据库 6 | 7 | 然后创建**config.php** 8 | ```php 9 | 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql.8 6 | true 7 | com.mysql.cj.jdbc.Driver 8 | jdbc:mysql://1.117.11.242:3306/msg_jsun_limecho 9 | $ProjectFileDir$ 10 | 11 | 12 | -------------------------------------------------------------------------------- /submit.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 留言成功 9 | 10 | 11 | prepare("INSERT INTO message (`is_anonymous`,`ip`,`name`,`email`,`message`) VALUES (?,?,?,?,?)")) { 15 | $stmt->bind_param("issss", $isAnonymous, $ip, $name, $email, $message); 16 | $isAnonymous = (bool)$_POST["isAnonymous"]; 17 | $ip = $_SERVER['REMOTE_ADDR']; 18 | $name = $_POST["name"]; 19 | $email = $_POST["email"]; 20 | $message = $_POST["message"]; 21 | $stmt->execute(); 22 | } 23 | ?> 24 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /js/index.js: -------------------------------------------------------------------------------- 1 | const $ = mdui.$; 2 | 3 | if (localStorage.getItem('name')) { 4 | $('.userInfoInput').prop('value', index => localStorage.getItem(index ? 'email' : 'name')); 5 | } 6 | 7 | let colorIndex = localStorage.getItem('color') ? +localStorage.getItem('color') : 4; 8 | const color = ['red', 'pink', 'purple', 'deep-purple', 'indigo', 'teal', 'brown', 'blue-grey']; 9 | $('body').addClass(`mdui-theme-primary-${color[colorIndex]} mdui-theme-accent-pink`); 10 | 11 | let userInfoTmp = []; 12 | $('#isAnonymous').on('click', () => { 13 | $('.userInfoInput').prop({ 14 | 'disabled': $('#isAnonymous').prop('checked'), 15 | 'value': (index, oldValue) => { 16 | if ($('#isAnonymous').prop('checked')) { 17 | userInfoTmp[index] = oldValue; 18 | return ''; 19 | } else { 20 | return userInfoTmp[index]; 21 | } 22 | } 23 | }); 24 | mdui.updateTextFields($('.userInfo')); 25 | }); 26 | 27 | $('#submit').on('click', () => { 28 | if (!$('#isAnonymous').prop('checked')) { 29 | $('.userInfoInput').prop('value', (index, oldValue) => { 30 | localStorage.setItem(index ? 'email' : 'name', oldValue); 31 | }); 32 | } 33 | }); 34 | 35 | $('#reset').on('click', () => { 36 | localStorage.removeItem('name'); 37 | localStorage.removeItem('email'); 38 | }); 39 | 40 | $('#color').on('click', () => { 41 | colorIndex = colorIndex === 7 ? 0 : colorIndex + 1; 42 | $('body').removeClass().addClass(`mdui-theme-primary-${color[colorIndex]} mdui-theme-accent-pink`); 43 | localStorage.setItem('color', colorIndex); 44 | }); 45 | -------------------------------------------------------------------------------- /message.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 5.0.4 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- 主机: localhost 6 | -- 生成日期: 2021-06-06 16:34:51 7 | -- 服务器版本: 8.0.24 8 | -- PHP 版本: 8.0.6 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | START TRANSACTION; 12 | SET time_zone = "+00:00"; 13 | 14 | 15 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 16 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 17 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 18 | /*!40101 SET NAMES utf8mb4 */; 19 | 20 | -- 21 | -- 数据库: `just_for_test` 22 | -- 23 | 24 | -- -------------------------------------------------------- 25 | 26 | -- 27 | -- 表的结构 `message` 28 | -- 29 | 30 | CREATE TABLE `message` ( 31 | `id` int NOT NULL, 32 | `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 33 | `ip` varchar(150) DEFAULT NULL, 34 | `is_anonymous` tinyint(1) NOT NULL, 35 | `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, 36 | `email` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, 37 | `message` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL 38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; 39 | 40 | -- 41 | -- 转储表的索引 42 | -- 43 | 44 | -- 45 | -- 表的索引 `message` 46 | -- 47 | ALTER TABLE `message` 48 | ADD PRIMARY KEY (`id`); 49 | 50 | -- 51 | -- 在导出的表使用AUTO_INCREMENT 52 | -- 53 | 54 | -- 55 | -- 使用表AUTO_INCREMENT `message` 56 | -- 57 | ALTER TABLE `message` 58 | MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=69; 59 | COMMIT; 60 | 61 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 62 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 63 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/phpstorm 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=phpstorm 4 | 5 | ### PhpStorm ### 6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 7 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 8 | 9 | # User-specific stuff 10 | .idea/**/workspace.xml 11 | .idea/**/tasks.xml 12 | .idea/**/usage.statistics.xml 13 | .idea/**/dictionaries 14 | .idea/**/shelf 15 | 16 | # Generated files 17 | .idea/**/contentModel.xml 18 | 19 | # Sensitive or high-churn files 20 | .idea/**/dataSources/ 21 | .idea/**/dataSources.ids 22 | .idea/**/dataSources.local.xml 23 | .idea/**/sqlDataSources.xml 24 | .idea/**/dynamic.xml 25 | .idea/**/uiDesigner.xml 26 | .idea/**/dbnavigator.xml 27 | 28 | # Gradle 29 | .idea/**/gradle.xml 30 | .idea/**/libraries 31 | 32 | # Gradle and Maven with auto-import 33 | # When using Gradle or Maven with auto-import, you should exclude module files, 34 | # since they will be recreated, and may cause churn. Uncomment if using 35 | # auto-import. 36 | # .idea/artifacts 37 | # .idea/compiler.xml 38 | # .idea/jarRepositories.xml 39 | # .idea/modules.xml 40 | # .idea/*.iml 41 | # .idea/modules 42 | # *.iml 43 | # *.ipr 44 | 45 | # CMake 46 | cmake-build-*/ 47 | 48 | # Mongo Explorer plugin 49 | .idea/**/mongoSettings.xml 50 | 51 | # File-based project format 52 | *.iws 53 | 54 | # IntelliJ 55 | out/ 56 | 57 | # mpeltonen/sbt-idea plugin 58 | .idea_modules/ 59 | 60 | # JIRA plugin 61 | atlassian-ide-plugin.xml 62 | 63 | # Cursive Clojure plugin 64 | .idea/replstate.xml 65 | 66 | # Crashlytics plugin (for Android Studio and IntelliJ) 67 | com_crashlytics_export_strings.xml 68 | crashlytics.properties 69 | crashlytics-build.properties 70 | fabric.properties 71 | 72 | # Editor-based Rest Client 73 | .idea/httpRequests 74 | 75 | # Android studio 3.1+ serialized cache file 76 | .idea/caches/build_file_checksums.ser 77 | 78 | ### PhpStorm Patch ### 79 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 80 | 81 | # *.iml 82 | # modules.xml 83 | # .idea/misc.xml 84 | # *.ipr 85 | 86 | # Sonarlint plugin 87 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 88 | .idea/**/sonarlint/ 89 | 90 | # SonarQube Plugin 91 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 92 | .idea/**/sonarIssues.xml 93 | 94 | # Markdown Navigator plugin 95 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 96 | .idea/**/markdown-navigator.xml 97 | .idea/**/markdown-navigator-enh.xml 98 | .idea/**/markdown-navigator/ 99 | 100 | # Cache file creation bug 101 | # See https://youtrack.jetbrains.com/issue/JBR-2257 102 | .idea/$CACHE_FILE$ 103 | 104 | # CodeStream plugin 105 | # https://plugins.jetbrains.com/plugin/12206-codestream 106 | .idea/codestream.xml 107 | 108 | # End of https://www.toptal.com/developers/gitignore/api/phpstorm 109 | 110 | # Private config file 111 | config.php -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | <?php echo title; ?> 17 | 18 | 19 |
20 |
21 |
22 |
23 | color_lens 24 | 26 | 29 | 35 | 36 | 37 |
38 |
39 |
40 |
41 |
42 | account_circle 43 | 44 | 45 |
昵称不能为空
46 |
47 |
48 | email 49 | 50 | 51 |
邮箱格式错误
52 |
53 |
54 | 56 |
内容不能为空
57 |
58 |
59 | 64 |
65 | 69 | 73 |
74 |
75 |
76 | query("SELECT date,is_anonymous,name,email,message FROM message ORDER BY id DESC"); 79 | foreach ($messages as $message) { 80 | if ($message["is_anonymous"]) { ?> 81 |
82 |
83 |
format("Y年m月d日 H:i:s"); ?>
85 |
匿名
86 |
87 |
88 |
89 | 90 |
91 |
92 |
format("Y年m月d日 H:i:s"); ?>
94 |
95 |
96 |
97 |
98 | 99 | 100 | 101 | 102 |
103 | 108 | 109 | 110 | --------------------------------------------------------------------------------