added foreign key to database
This commit is contained in:
@@ -12,9 +12,9 @@
|
|||||||
<table>
|
<table>
|
||||||
<caption>Table: message</caption>
|
<caption>Table: message</caption>
|
||||||
<tr><th>Colum Name</th><th>SQL Type</th><th>Description</th></tr>
|
<tr><th>Colum Name</th><th>SQL Type</th><th>Description</th></tr>
|
||||||
<tr><td>id</td><td>int</td><td>Incrementing message id starting at 1.</td></tr>
|
<tr><td>id</td><td>int, primary key</td><td>Incrementing message id starting at 1.</td></tr>
|
||||||
<tr><td>time</td><td>timestamp</td><td>Time when message has been stored in the database.</td></tr>
|
<tr><td>time</td><td>timestamp</td><td>Time when message has been stored in the database.</td></tr>
|
||||||
<tr><td>user</td><td>varchar(50)</td><td>The sender's user name (pseudonym).</td></tr>
|
<tr><td>user</td><td>varchar(50), references \ref usertable "user (name)"</td><td>The sender's user name (pseudonym).</td></tr>
|
||||||
<tr><td>msg</td><td>longtext</td><td>The encryped and armored message text.</td></tr>
|
<tr><td>msg</td><td>longtext</td><td>The encryped and armored message text.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
require_once("opendb.php");
|
require_once("opendb.php");
|
||||||
try {
|
try {
|
||||||
$db->query('create table if not exists message (id int primary key not null auto_increment, time timestamp default current_timestamp, user varchar(50) not null, msg longtext not null);');
|
$db->query('create table if not exists message (id int primary key not null auto_increment, time timestamp default current_timestamp, user varchar(50) not null, msg longtext not null, foreign key (user) references user(name) on delete cascade on update cascade) character set utf8 engine=innodb;');
|
||||||
$db->query('set global max_allowed_packet=1000000000');
|
$db->query('set global max_allowed_packet=1000000000');
|
||||||
$db->query('set global net_buffer_length=1000000');
|
$db->query('set global net_buffer_length=1000000');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@@ -686,4 +686,13 @@ function start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// On Load, Call @ref start
|
/// On Load, Call @ref start
|
||||||
$(start);
|
$(
|
||||||
|
window.onbeforeunload = function() {
|
||||||
|
return "Are you sure you want to navigate away?";
|
||||||
|
}
|
||||||
|
window.onunload = function () { // you probably don't want to leave now...
|
||||||
|
alert('You are trying to leave.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
start();
|
||||||
|
);
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<caption>Table: user</caption>
|
<caption>Table: user</caption>
|
||||||
<tr><th>Colum Name</th><th>SQL Type</th><th>Description</th></tr>
|
<tr><th>Colum Name</th><th>SQL Type</th><th>Description</th></tr>
|
||||||
<tr><td>name</td><td>varchar(50)</td><td>The user's name (pseudonym).</td></tr>
|
<tr><td>name</td><td>varchar(50), primary key</td><td>The user's name (pseudonym).</td></tr>
|
||||||
<tr><td>pubkey</td><td>text</td><td>The user's public key.</td></tr>
|
<tr><td>pubkey</td><td>text</td><td>The user's public key.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
require_once("opendb.php");
|
require_once("opendb.php");
|
||||||
try {
|
try {
|
||||||
$db->query('create table if not exists user (name varchar(50) not null unique key, pubkey text not null);');
|
$db->query('create table if not exists user (name varchar(50) not null primary key, pubkey text not null) character set utf8 engine=innodb;');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
error('database error on server');
|
error('database error on server');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user