Parcourir la source

Cleanup

- create-tables commented
- moved more toplevel functions into static classes
- removed hard coded time zone array
- session cookie now persists for 2 weeks
- better comments, line wrapping
- trace logging moved to dedicated trace function
- URLs with no trailing slash better handled
- validate improvements
- proper HTTP error codes for bad request methods or missing POST actions
master
Rocketsoup il y a 3 ans
Parent
révision
cf52c5ec33
3 fichiers modifiés avec 387 ajouts et 639 suppressions
  1. 374
    630
      htdocs/index.php
  2. 4
    0
      htdocs/journal.css
  3. 9
    9
      source/create-tables.sql

+ 374
- 630
htdocs/index.php
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 4
- 0
htdocs/journal.css Voir le fichier

@@ -8,8 +8,12 @@
8 8
 	font-size: 12pt;
9 9
 }
10 10
 .error {
11
+	padding: 1em;
12
+	border: 1px solid #400;
13
+	background-color: #fcc;
11 14
 	color: #d00;
12 15
 	font-weight: bold;
16
+	margin-bottom: 1em;
13 17
 }
14 18
 .post {
15 19
 	margin-top: 0.5em;

+ 9
- 9
source/create-tables.sql Voir le fichier

@@ -4,23 +4,23 @@ PRAGMA foreign_keys = ON;
4 4
 
5 5
 DROP TABLE IF EXISTS config;
6 6
 CREATE TABLE config (
7
-	name TEXT UNIQUE,
8
-	value ANY
7
+	name TEXT UNIQUE,  -- variable name
8
+	value ANY          -- variable value
9 9
 );
10 10
 
11 11
 DROP TABLE IF EXISTS users;
12 12
 CREATE TABLE users (
13
-	user_id INTEGER PRIMARY KEY,
14
-	username TEXT UNIQUE COLLATE NOCASE,
15
-	password_hash TEXT,
16
-	timezone TEXT DEFAULT 'America/Los_Angeles'
13
+	user_id INTEGER PRIMARY KEY,                 -- PK
14
+	username TEXT UNIQUE COLLATE NOCASE,         -- can be username or email
15
+	password_hash TEXT,                          -- output of password_hash()
16
+	timezone TEXT DEFAULT 'America/Los_Angeles'  -- for date formatting
17 17
 );
18 18
 
19 19
 DROP TABLE IF EXISTS posts;
20 20
 CREATE TABLE posts (
21
-	body TEXT,
22
-	created INTEGER,
23
-	author_id INTEGER NOT NULL,
21
+	body TEXT,                    -- main text of the post
22
+	created INTEGER,              -- timestamp when the post was created
23
+	author_id INTEGER NOT NULL,   -- user_id of author
24 24
 	FOREIGN KEY (author_id) REFERENCES users (user_id)
25 25
 );
26 26
 

Chargement…
Annuler
Enregistrer