+
+
+
diff --git a/classes/db-class.php b/classes/db-class.php
index 914d8c0..b9fe130 100644
--- a/classes/db-class.php
+++ b/classes/db-class.php
@@ -40,4 +40,16 @@ class SSDB
}
}
+ function updateSetting($conn, $settingname, $settingvalue){
+ $this->deleteSetting($conn, $settingname);
+ $this->setSetting($conn, $settingname, $settingvalue);
+ return true;
+ }
+
+ function getBooleanSetting($conn, $setting) {
+ if (trim($this->getSetting($conn, $setting)) == "yes"){
+ return true;
+ }
+ return false;
+ }
}
diff --git a/classes/queue.php b/classes/queue.php
index 9d04ca9..dd8187c 100644
--- a/classes/queue.php
+++ b/classes/queue.php
@@ -98,7 +98,7 @@ class Queue
$this->set_task_status($this->all_status['ready']); // Make task available for release
}
- public function update_notfication_retries($task_id, $subscriber_id) {
+ public function update_notification_retries($task_id, $subscriber_id) {
global $mysqli;
$stmt = $mysqli->prepare("UPDATE queue_notify SET retries = retries+1 WHERE task_id = ? AND subscriber_id = ?");
$stmt->bind_param("ii", $task_id, $subscriber_id);
@@ -126,12 +126,12 @@ class Queue
$tmp = $stmt2->get_result();
$result2 = $tmp->fetch_assoc();
$typeID = $result2['type_id'];
-
+
// Handle telegram
if ($typeID == 1) {
$msg = str_replace("#s", $result['firstname'], $result2['template_data2']);
if ( ! Notification::submit_queue_telegram($result['userID'], $result['firstname'], $msg) ) {
- Queue::update_notfication_retries($result['task_id'], $result['subscriber_id']); // Sent
+ Queue::update_notification_retries($result['task_id'], $result['subscriber_id']); // Sent
} else {
Queue::delete_notification($result['task_id'], $result['subscriber_id']); // Failed
}
diff --git a/config.php.template b/config.php.template
index 7722444..cc293d8 100644
--- a/config.php.template
+++ b/config.php.template
@@ -31,26 +31,10 @@ define("POLICY_MAIL", "##policy_mail##"); //contact email in policy
define("POLICY_PHONE", "##policy_phone##");
define("WHO_WE_ARE","##who_we_are##");
define("POLICY_URL","##policy_url##");
-define('SUBSCRIBE_EMAIL', true);
-define('SUBSCRIBE_TELEGRAM', false);
-define("TG_BOT_API_TOKEN", "##tg_bot_token##"); //Telegram Bot Token
-define("TG_BOT_USERNAME", "##tg_bot_username##"); //Telegram Bot username
define("INSTALL_OVERRIDE", false);
define("DEFAULT_LANGUAGE", "en_GB");
-define("GOOGLE_RECAPTCHA", false);
-define("GOOGLE_RECAPTCHA_SITEKEY", "##google_site_key##");
-define("GOOGLE_RECAPTCHA_SECRET", "##google_secret##");
-define("PHP_MAILER", false); // Enable if we are to use extenral PHPMailer() library
-define("PHP_MAILER_PATH", "##phpmailer_path##"); // Path to src folder of PHPMailer() library - without ending /
-define("PHP_MAILER_SMTP", false); // Set to true if we are to use SMTP
-define("PHP_MAILER_HOST", "##phpmailer_host##"); // SMTP host
-define("PHP_MAILER_PORT", "##phpmailer_port##"); // SMTP Port
-define("PHP_MAILER_SECURE", ""); // Set to TLS or SSL or leave blank for plaintext
-define("PHP_MAILER_USER", "##phpmailer_user##"); // SMTP Authentication user
-define("PHP_MAILER_PASS", "##phpmailer_pass##"); // SMTP authenticatin password
define("CUSTOM_LOGO_URL",""); // This will use the default logo if left empty
define("COPYRIGHT_TEXT",""); // Leave this empty if you don't want your copyright displayed
-define("CRON_SERVER_IP",""); // IP Address that will be used to call cron task. Leave empty if not used!
// Without COPYRIGHT_TEXT Set
// 2020 Server Status Project Contributors
// With COPYRIGHT_TEXT Set
diff --git a/email_subscriptions.php b/email_subscriptions.php
index bd35da9..366c2be 100644
--- a/email_subscriptions.php
+++ b/email_subscriptions.php
@@ -13,6 +13,23 @@ define("TITLE", $db->getSetting($mysqli,"title"));
define("WEB_URL", $db->getSetting($mysqli,"url"));
define("MAILER_NAME", $db->getSetting($mysqli,"mailer"));
define("MAILER_ADDRESS", $db->getSetting($mysqli,"mailer_email"));
+define("GOOGLE_RECAPTCHA", $db->getBooleanSetting($mysqli, "google_recaptcha"));
+//define("", $db->getSettings($mysqli, ""));
+define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli, "google_recaptcha_secret"));
+define("GOOGLE_RECAPTCHA_SITEKEY", $db->getSetting($mysqli, "google_recaptcha_sitekey"));
+define("SUBSCRIBE_EMAIL", $db->getBooleanSetting($mysqli, "subscribe_email"));
+define("SUBSCRIBE_TELEGRAM", $db->getBooleanSetting($mysqli, "subscribe_telegram"));
+define("TG_BOT_USERNAME", $db->getSetting($mysqli, "tg_bot_username"));
+define("TG_BOT_API_TOKEN", $db->getSetting($mysqli, "tg_bot_api_token"));
+define("PHP_MAILER", $db->getBooleanSetting($mysqli, "php_mailer"));
+define("PHP_MAILER_SMTP", $db->getBooleanSetting($mysqli, "php_mailer_smtp"));
+define("PHP_MAILER_PATH", $db->getSetting($mysqli, "php_mailer_path"));
+define("PHP_MAILER_HOST", $db->getSetting($mysqli, "php_mailer_host"));
+define("PHP_MAILER_PORT", $db->getSetting($mysqli, "php_mailer_port"));
+define("PHP_MAILER_SECURE", $db->getBooleanSetting($mysqli, "php_mailer_secure"));
+define("PHP_MAILER_USER", $db->getSetting($mysqli, "php_mailer_user"));
+define("PHP_MAILER_PASS", $db->getSetting($mysqli, "php_mailer_pass"));
+
$mailer = new Mailer();
$subscriber = new Subscriber();
$subscription = new Subscriptions();
@@ -25,18 +42,18 @@ if ( isset($_GET['new']) ) {
// Form validation for subscribers signing up
$message = "";
Template :: render_header(_("Email Subscription"));
-
+
if (isset($_POST['emailaddress'])) {
-
+
if (0 == strlen(trim($_POST['emailaddress']))){
$messages[] = _("Email address");
}
-
+
// Perform DNS domain validation on
if ( ! $mailer->verify_domain($_POST['emailaddress']) ) {
$messages[] = _("Domain does not apper to be a valid email domain. (Check MX record)");
}
-
+
if (GOOGLE_RECAPTCHA) {
// Validate recaptcha
$response = $_POST["g-recaptcha-response"];
@@ -70,7 +87,7 @@ if ( isset($_GET['new']) ) {
if(isset($_POST['emailaddress']) && empty($message))
{
- // Check if email is already registered
+ // Check if email is already registered
$boolUserExist = false;
$subscriber->userID = $_POST['emailaddress'];
$subscriber->typeID = 2; // Email
@@ -82,17 +99,17 @@ if ( isset($_GET['new']) ) {
// Create a new subscriber as it does not exist
$subscriber->add($subscriber->typeID, $_POST['emailaddress']);
$url = WEB_URL."/index.php?do=manage&token=".$subscriber->token; // Needed again after adding subscriber since token did not exist before add
- $msg = sprintf(_("Thank you for registering to receive status updates via email. Click on the following link to confirm and manage your subcription: %s. New subscriptions must be confirmed within 2 hours"), $url, NAME .' - ' . _("Validate subscription"));
-
+ $msg = sprintf(_("Thank you for registering to receive status updates via email. Click on the following link to confirm and manage your subcription: %s. New subscriptions must be confirmed within 2 hours"), $url, NAME .' - ' . _("Validate subscription"));
+
} else {
if ( ! $subscriber->active ) {
// Subscriber is registered, but has not been activated yet...
$msg = sprintf(_("Thank you for registering to receive status updates via email. Click on the following link to confirm and manage your subcription: %s. New subscriptions must be confirmed within 2 hours"), $url, NAME .' - ' . _("Validate subscription"));
$subscriber->activate($subscriber->id);
-
+
} else {
// subscriber is registered and active
- $msg = sprintf(_("Click on the following link to update your existing subscription: %s"), $url, NAME .' - ' . _("Manage subscription"));
+ $msg = sprintf(_("Click on the following link to update your existing subscription: %s"), $url, NAME .' - ' . _("Manage subscription"));
$subscriber->update($subscriber->id);
}
}
@@ -101,10 +118,10 @@ if ( isset($_GET['new']) ) {
$message = _("You will receive an email shortly with an activation link. Please click on the link to activate and/or manage your subscription.");
$constellation->render_success($header, $message, true, WEB_URL, _('Go back'));
- // Send email about new registration
+ // Send email about new registration
$subject = _('Email subscription registered').' - '.NAME;
$mailer->send_mail($_POST['emailaddress'], $subject, $msg);
-
+
$boolRegistered = true;
}
@@ -116,8 +133,8 @@ if ( isset($_GET['new']) ) {
}
$strPostedEmail = (isset($_POST['emailaddress'])) ? $_POST['emailaddress'] : "";
?>
-
-
+
+