diff --git a/html/makefile.am b/html/makefile.am
index cd410ae..fd620cb 100644
--- a/html/makefile.am
+++ b/html/makefile.am
@@ -17,7 +17,7 @@ dist_www_DATA = index.html chat.html newuser.html safechat.js \
envelope.svg functions.php menu.svg pfeil.svg \
photo.png photo.svg safechat-rodrigo-angleton.svg \
safe-mimooh.svg send.svg update-messages.js video.png \
- video.svg
+ video.svg messagetable.sql usertable.sql
EXTRA_DIST = documentation.dox
diff --git a/html/messagetable.php b/html/messagetable.php
index 76d750e..bbb9fb8 100644
--- a/html/messagetable.php
+++ b/html/messagetable.php
@@ -23,29 +23,7 @@
require_once("opendb.php");
try {
- $query = <<query($query);
+ $db->query(file_get_contents("messagetable.sql"));
$db->query('set global max_allowed_packet=1000000000');
$db->query('set global net_buffer_length=1000000');
} catch (Exception $e) {
diff --git a/html/messagetable.sql b/html/messagetable.sql
new file mode 100644
index 0000000..3abaf2d
--- /dev/null
+++ b/html/messagetable.sql
@@ -0,0 +1,20 @@
+ create table if not exists
+ 'message' (
+ 'id'
+ int primary key not null auto_increment
+ comment "id of the message, it is used in the client to check if a message has already been downloaded or not",
+ 'time'
+ timestamp default current_timestamp
+ comment "time when the message has been stored on the server",
+ 'user'
+ varchar(50) not null
+ comment "name of the user that sent the message",
+ 'msg'
+ longtext not null
+ comment "message content, must be armored gnupg encrypted format",
+ foreign key ('user')
+ references 'user'('name')
+ on delete cascade
+ on update cascade
+ ) character set utf8 engine=innodb
+ comment="table to hold all messages for later download by the receiver";
diff --git a/html/usertable.php b/html/usertable.php
index 553a362..4baa65e 100644
--- a/html/usertable.php
+++ b/html/usertable.php
@@ -24,19 +24,7 @@
require_once("opendb.php");
try {
- $query = <<query($query);
+ $db->query(file_get_contents("usertable.sql"));
} catch (Exception $e) {
error('database error on server');
}
diff --git a/html/usertable.sql b/html/usertable.sql
new file mode 100644
index 0000000..097668a
--- /dev/null
+++ b/html/usertable.sql
@@ -0,0 +1,5 @@
+CREATE TABLE IF NOT EXISTS `user` (
+ `name` varchar(50) NOT NULL COMMENT 'unique name of the user',
+ `pubkey` text NOT NULL COMMENT 'armored gnupg public key of the user',
+ PRIMARY KEY (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='list of all registered users and their public keys';