feat!: allow registration of multiple users (#340)
feat: administration area feat: add reset password functionality
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
@@ -28,8 +27,10 @@ require_once '../../includes/connect_endpoint.php';
|
||||
$bot_username = $data["bot_username"];
|
||||
$bot_avatar_url = $data["bot_avatar"];
|
||||
|
||||
$query = "SELECT COUNT(*) FROM discord_notifications";
|
||||
$result = $db->querySingle($query);
|
||||
$query = "SELECT COUNT(*) FROM discord_notifications WHERE user_id = :userId";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
@@ -38,12 +39,15 @@ require_once '../../includes/connect_endpoint.php';
|
||||
];
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
$query = "INSERT INTO discord_notifications (enabled, webhook_url, bot_username, bot_avatar_url)
|
||||
VALUES (:enabled, :webhook_url, :bot_username, :bot_avatar_url)";
|
||||
$row = $result->fetchArray();
|
||||
$count = $row[0];
|
||||
if ($count == 0) {
|
||||
$query = "INSERT INTO discord_notifications (enabled, webhook_url, bot_username, bot_avatar_url, user_id)
|
||||
VALUES (:enabled, :webhook_url, :bot_username, :bot_avatar_url, :userId)";
|
||||
} else {
|
||||
$query = "UPDATE discord_notifications
|
||||
SET enabled = :enabled, webhook_url = :webhook_url, bot_username = :bot_username, bot_avatar_url = :bot_avatar_url";
|
||||
SET enabled = :enabled, webhook_url = :webhook_url, bot_username = :bot_username, bot_avatar_url = :bot_avatar_url
|
||||
WHERE user_id = :userId";
|
||||
}
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
@@ -51,6 +55,7 @@ require_once '../../includes/connect_endpoint.php';
|
||||
$stmt->bindValue(':webhook_url', $webhook_url, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':bot_username', $bot_username, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':bot_avatar_url', $bot_avatar_url, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
@@ -36,8 +35,10 @@
|
||||
$smtpPassword = $data["smtppassword"];
|
||||
$fromEmail = $data["fromemail"];
|
||||
|
||||
$query = "SELECT COUNT(*) FROM email_notifications";
|
||||
$result = $db->querySingle($query);
|
||||
$query = "SELECT COUNT(*) FROM email_notifications WHERE user_id = :userId";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
@@ -46,13 +47,15 @@
|
||||
];
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
$query = "INSERT INTO email_notifications (enabled, smtp_address, smtp_port, smtp_username, smtp_password, from_email, encryption)
|
||||
VALUES (:enabled, :smtpAddress, :smtpPort, :smtpUsername, :smtpPassword, :fromEmail, :encryption)";
|
||||
$row = $result->fetchArray();
|
||||
$count = $row[0];
|
||||
if ($count == 0) {
|
||||
$query = "INSERT INTO email_notifications (enabled, smtp_address, smtp_port, smtp_username, smtp_password, from_email, encryption, user_id)
|
||||
VALUES (:enabled, :smtpAddress, :smtpPort, :smtpUsername, :smtpPassword, :fromEmail, :encryption, :userId)";
|
||||
} else {
|
||||
$query = "UPDATE email_notifications
|
||||
SET enabled = :enabled, smtp_address = :smtpAddress, smtp_port = :smtpPort,
|
||||
smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail, encryption = :encryption";
|
||||
smtp_username = :smtpUsername, smtp_password = :smtpPassword, from_email = :fromEmail, encryption = :encryption WHERE user_id = :userId";
|
||||
}
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
@@ -63,6 +66,7 @@
|
||||
$stmt->bindValue(':smtpPassword', $smtpPassword, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':fromEmail', $fromEmail, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':encryption', $encryption, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
@@ -27,8 +26,10 @@
|
||||
$url = $data["gotify_url"];
|
||||
$token = $data["token"];
|
||||
|
||||
$query = "SELECT COUNT(*) FROM gotify_notifications";
|
||||
$result = $db->querySingle($query);
|
||||
$query = "SELECT COUNT(*) FROM gotify_notifications WHERE user_id = :userId";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
@@ -37,18 +38,21 @@
|
||||
];
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
$query = "INSERT INTO gotify_notifications (enabled, url, token)
|
||||
VALUES (:enabled, :url, :token)";
|
||||
$row = $result->fetchArray();
|
||||
$count = $row[0];
|
||||
if ($count == 0) {
|
||||
$query = "INSERT INTO gotify_notifications (enabled, url, token, user_id)
|
||||
VALUES (:enabled, :url, :token, :userId)";
|
||||
} else {
|
||||
$query = "UPDATE gotify_notifications
|
||||
SET enabled = :enabled, url = :url, token = :token";
|
||||
SET enabled = :enabled, url = :url, token = :token WHERE user_id = :userId";
|
||||
}
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindValue(':enabled', $enabled, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':url', $url, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':token', $token, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
@@ -22,8 +21,10 @@
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
$days = $data["days"];
|
||||
$query = "SELECT COUNT(*) FROM notification_settings";
|
||||
$result = $db->querySingle($query);
|
||||
$query = "SELECT COUNT(*) FROM notification_settings WHERE user_id = :userId";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
@@ -32,15 +33,18 @@
|
||||
];
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
$query = "INSERT INTO notification_settings (days)
|
||||
VALUES (:days)";
|
||||
$row = $result->fetchArray();
|
||||
$count = $row[0];
|
||||
if ($count == 0) {
|
||||
$query = "INSERT INTO notification_settings (days, user_id)
|
||||
VALUES (:days, :userId)";
|
||||
} else {
|
||||
$query = "UPDATE notification_settings SET days = :days";
|
||||
$query = "UPDATE notification_settings SET days = :days WHERE user_id = :userId";
|
||||
}
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindValue(':days', $days, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
@@ -28,8 +27,10 @@ require_once '../../includes/connect_endpoint.php';
|
||||
$user_key = $data["user_key"];
|
||||
$token = $data["token"];
|
||||
|
||||
$query = "SELECT COUNT(*) FROM pushover_notifications";
|
||||
$result = $db->querySingle($query);
|
||||
$query = "SELECT COUNT(*) FROM pushover_notifications WHERE user_id = :userId";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
@@ -38,18 +39,21 @@ require_once '../../includes/connect_endpoint.php';
|
||||
];
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
$query = "INSERT INTO pushover_notifications (enabled, user_key, token)
|
||||
VALUES (:enabled, :user_key, :token)";
|
||||
$row = $result->fetchArray();
|
||||
$count = $row[0];
|
||||
if ($count == 0) {
|
||||
$query = "INSERT INTO pushover_notifications (enabled, user_key, token, user_id)
|
||||
VALUES (:enabled, :user_key, :token, :userId)";
|
||||
} else {
|
||||
$query = "UPDATE pushover_notifications
|
||||
SET enabled = :enabled, user_key = :user_key, token = :token";
|
||||
SET enabled = :enabled, user_key = :user_key, token = :token, user_id = :userId";
|
||||
}
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindValue(':enabled', $enabled, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':user_key', $user_key, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':token', $token, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
@@ -27,8 +26,10 @@
|
||||
$bot_token = $data["bot_token"];
|
||||
$chat_id = $data["chat_id"];
|
||||
|
||||
$query = "SELECT COUNT(*) FROM telegram_notifications";
|
||||
$result = $db->querySingle($query);
|
||||
$query = "SELECT COUNT(*) FROM telegram_notifications WHERE user_id = :userId";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
@@ -37,18 +38,21 @@
|
||||
];
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
$query = "INSERT INTO telegram_notifications (enabled, bot_token, chat_id)
|
||||
VALUES (:enabled, :bot_token, :chat_id)";
|
||||
$row = $result->fetchArray();
|
||||
$count = $row[0];
|
||||
if ($count == 0) {
|
||||
$query = "INSERT INTO telegram_notifications (enabled, bot_token, chat_id, user_id)
|
||||
VALUES (:enabled, :bot_token, :chat_id, :userId)";
|
||||
} else {
|
||||
$query = "UPDATE telegram_notifications
|
||||
SET enabled = :enabled, bot_token = :bot_token, chat_id = :chat_id";
|
||||
SET enabled = :enabled, bot_token = :bot_token, chat_id = :chat_id WHERE user_id = :userId";
|
||||
}
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindValue(':enabled', $enabled, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':bot_token', $bot_token, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':chat_id', $chat_id, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
@@ -28,8 +27,10 @@
|
||||
$headers = $data["headers"];
|
||||
$payload = $data["payload"];
|
||||
|
||||
$query = "SELECT COUNT(*) FROM webhook_notifications";
|
||||
$result = $db->querySingle($query);
|
||||
$query = "SELECT COUNT(*) FROM webhook_notifications WHERE user_id = :userId";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
@@ -38,12 +39,14 @@
|
||||
];
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
$query = "INSERT INTO webhook_notifications (enabled, url, headers, payload)
|
||||
VALUES (:enabled, :url, :headers, :payload)";
|
||||
$row = $result->fetchArray();
|
||||
$count = $row[0];
|
||||
if ($count == 0) {
|
||||
$query = "INSERT INTO webhook_notifications (enabled, url, headers, payload, user_id)
|
||||
VALUES (:enabled, :url, :headers, :payload, :userId)";
|
||||
} else {
|
||||
$query = "UPDATE webhook_notifications
|
||||
SET enabled = :enabled, url = :url, headers = :headers, payload = :payload";
|
||||
SET enabled = :enabled, url = :url, headers = :headers, payload = :payload WHERE user_id = :userId";
|
||||
}
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
@@ -51,6 +54,7 @@
|
||||
$stmt->bindValue(':url', $url, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':headers', $headers, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':payload', $payload, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
|
||||
@@ -5,7 +5,6 @@ use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
|
||||
Reference in New Issue
Block a user