@@ -133,26 +205,47 @@
@@ -133,26 +205,47 @@
diff --git a/chat.php b/chat.php index 9dd928395..c4659e125 100644 --- a/chat.php +++ b/chat.php @@ -1,5 +1,6 @@ -
+ + + + + busyTimeout(5000) ) + { + if( $db->exec("PRAGMA journal_mode = wal;") ) + { + $logtable = "CREATE TABLE IF NOT EXISTS chatpack_log + (id INTEGER PRIMARY KEY, + timestamp INTEGER NOT NULL, + user TEXT NOT NULL, + avatar TEXT NOT NULL, + message TEXT NOT NULL, + liked INTEGER DEFAULT 0)"; + + if( $db->exec($logtable) ) + { + $usertable = "CREATE TABLE IF NOT EXISTS chatpack_typing + (id INTEGER PRIMARY KEY, + timestamp INTEGER NOT NULL, + user TEXT NOT NULL)"; + + if( $db->exec($usertable) ) + { + $dbcreated = true; + } + else + { + errormessage("creating database table for typing"); + } + } + else + { + errormessage("creating database table for messages"); + } + + if( !$db->close() ) + { + errormessage("closing database connection"); + } + } + else + { + errormessage("setting journal mode"); + } + } + else + { + errormessage("setting busy timeout"); + } + } + else + { + errormessage("using SQLite"); + } + + if( $dbcreated ) + { + + ?> +