- set Register_Accept to 6 internally as it reflects the same state as PendingSendRequest - cleanups
56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
$db_file = dirname(__DIR__)."/db_file.sqlite";
|
|
|
|
abstract class RegisterState
|
|
{
|
|
// Sending an E-Mail failed in the first attempt. Will retry later
|
|
const PendingEmailSend = 0;
|
|
// User got a mail. We wait for it to verfiy
|
|
const PendingEmailVerify = 1;
|
|
// Sending a message to the register room failed on first attempt
|
|
const PendingAdminSend = 5;
|
|
// No admin has verified the registration yet
|
|
const PendingAdminVerify = 6;
|
|
// Registration failed on first attempt. Will retry
|
|
const PendingRegistration = 7;
|
|
|
|
// in this case we have to reset the password of the user (or should we store it for this case?)
|
|
const PendingSendRegistrationMail = 8;
|
|
|
|
// State to allow persisting in the database although an admin declined it.
|
|
// Will be removed regularly
|
|
const RegistrationAccepted = 6;
|
|
const RegistrationDeclined = 13;
|
|
|
|
// User got successfully registered. Will be cleaned up later
|
|
const AllDone = 100;
|
|
}
|
|
|
|
// create database file when not existent yet
|
|
if (!file_exists($db_file)) {
|
|
$db = new PDO('sqlite:' . $db_file);
|
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$db->exec("CREATE TABLE registrations(
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
state INT DEFAULT 0,
|
|
first_name TEXT,
|
|
last_name TEXT,
|
|
username TEXT,
|
|
note TEXT,
|
|
email TEXT,
|
|
verify_token TEXT,
|
|
admin_token TEXT,
|
|
request_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP)");
|
|
}
|
|
else {
|
|
// establish connection
|
|
$db = new PDO('sqlite:' . $db_file);
|
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
}
|
|
|
|
// set writeable when not set already
|
|
if (!is_writable($db_file)) {
|
|
chmod($db_file, 0777);
|
|
}
|
|
?>
|