uploadfilter/db.php

42 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2019-02-23 12:55:43 +01:00
<?php
$CONFIG = array();
$CONFIG['sqliteFile'] = 'uploadfilter.sqlite3';
$CONFIG['fileDir'] = '/tmp';
$CONFIG['validationCount'] = 1;
$CONFIG['emailTemplate'] = './email.template';
$db = new PDO('sqlite:' . $CONFIG['sqliteFile']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("CREATE TABLE IF NOT EXISTS files (
id INTEGER PRIMARY KEY,
filePath TEXT,
fileHash TEXT)");
$db->exec("CREATE TABLE IF NOT EXISTS emails (
id INTEGER PRIMARY KEY,
email TEXT,
firstName TEXT,
lastName TEXT,
UNIQUE(email))");
$db->exec("CREATE TABLE IF NOT EXISTS validations (
id INTEGER PRIMARY KEY,
fileId INTEGER,
email TEXT,
token TEXT,
validated BOOLEAN,
FOREIGN KEY(fileId) REFERENCES files(id),
FOREIGN KEY(email) REFERENCES emails(email))");
/*
// demo emails!
$query = $db->prepare("INSERT INTO emails (email,firstName,lastName) VALUES (:email,:firstName,:lastName);");
$query->execute(array(':email' => 'upload-filter1@example.com', ':firstName' => 'Firstname1', ':lastName' => 'Lastname1'));
$query->execute(array(':email' => 'upload-filter2@example.com', ':firstName' => 'Firstname2', ':lastName' => 'Lastname2'));
$query->execute(array(':email' => 'upload-filter3@example.com', ':firstName' => 'Firstname3', ':lastName' => 'Lastname3'));
$query->execute(array(':email' => 'upload-filter4@example.com', ':firstName' => 'Firstname4', ':lastName' => 'Lastname4'));
$query->execute(array(':email' => 'upload-filter5@example.com', ':firstName' => 'Firstname5', ':lastName' => 'Lastname5'));
*/