|
13 | 13 | define("WEB_URL", $db->getSetting($mysqli,"url")); |
14 | 14 | define("MAILER_NAME", $db->getSetting($mysqli,"mailer")); |
15 | 15 | define("MAILER_ADDRESS", $db->getSetting($mysqli,"mailer_email")); |
| 16 | +define("GOOGLE_RECAPTCHA", $db->getBooleanSetting($mysqli, "google_recaptcha")); |
| 17 | +//define("", $db->getSettings($mysqli, "")); |
| 18 | +define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli, "google_recaptcha_secret")); |
| 19 | +define("GOOGLE_RECAPTCHA_SITEKEY", $db->getSetting($mysqli, "google_recaptcha_sitekey")); |
| 20 | +define("SUBSCRIBE_EMAIL", $db->getBooleanSetting($mysqli, "subscribe_email")); |
| 21 | +define("SUBSCRIBE_TELEGRAM", $db->getBooleanSetting($mysqli, "subscribe_telegram")); |
| 22 | +define("TG_BOT_USERNAME", $db->getSetting($mysqli, "tg_bot_username")); |
| 23 | +define("TG_BOT_API_TOKEN", $db->getSetting($mysqli, "tg_bot_api_token")); |
| 24 | +define("PHP_MAILER", $db->getBooleanSetting($mysqli, "php_mailer")); |
| 25 | +define("PHP_MAILER_SMTP", $db->getBooleanSetting($mysqli, "php_mailer_smtp")); |
| 26 | +define("PHP_MAILER_PATH", $db->getSetting($mysqli, "php_mailer_path")); |
| 27 | +define("PHP_MAILER_HOST", $db->getSetting($mysqli, "php_mailer_host")); |
| 28 | +define("PHP_MAILER_PORT", $db->getSetting($mysqli, "php_mailer_port")); |
| 29 | +define("PHP_MAILER_SECURE", $db->getBooleanSetting($mysqli, "php_mailer_secure")); |
| 30 | +define("PHP_MAILER_USER", $db->getSetting($mysqli, "php_mailer_user")); |
| 31 | +define("PHP_MAILER_PASS", $db->getSetting($mysqli, "php_mailer_pass")); |
| 32 | + |
16 | 33 | $mailer = new Mailer(); |
17 | 34 | $subscriber = new Subscriber(); |
18 | 35 | $subscription = new Subscriptions(); |
|
25 | 42 | // Form validation for subscribers signing up |
26 | 43 | $message = ""; |
27 | 44 | Template :: render_header(_("Email Subscription")); |
28 | | - |
| 45 | + |
29 | 46 | if (isset($_POST['emailaddress'])) { |
30 | | - |
| 47 | + |
31 | 48 | if (0 == strlen(trim($_POST['emailaddress']))){ |
32 | 49 | $messages[] = _("Email address"); |
33 | 50 | } |
34 | | - |
| 51 | + |
35 | 52 | // Perform DNS domain validation on |
36 | 53 | if ( ! $mailer->verify_domain($_POST['emailaddress']) ) { |
37 | 54 | $messages[] = _("Domain does not apper to be a valid email domain. (Check MX record)"); |
38 | 55 | } |
39 | | - |
| 56 | + |
40 | 57 | if (GOOGLE_RECAPTCHA) { |
41 | 58 | // Validate recaptcha |
42 | 59 | $response = $_POST["g-recaptcha-response"]; |
|
70 | 87 | if(isset($_POST['emailaddress']) && empty($message)) |
71 | 88 | { |
72 | 89 |
|
73 | | - // Check if email is already registered |
| 90 | + // Check if email is already registered |
74 | 91 | $boolUserExist = false; |
75 | 92 | $subscriber->userID = $_POST['emailaddress']; |
76 | 93 | $subscriber->typeID = 2; // Email |
|
82 | 99 | // Create a new subscriber as it does not exist |
83 | 100 | $subscriber->add($subscriber->typeID, $_POST['emailaddress']); |
84 | 101 | $url = WEB_URL."/index.php?do=manage&token=".$subscriber->token; // Needed again after adding subscriber since token did not exist before add |
85 | | - $msg = sprintf(_("Thank you for registering to receive status updates via email.</br></br> Click on the following link to confirm and manage your subcription: <a href=\"%s\">%s</a>. New subscriptions must be confirmed within 2 hours"), $url, NAME .' - ' . _("Validate subscription")); |
86 | | - |
| 102 | + $msg = sprintf(_("Thank you for registering to receive status updates via email.</br></br> Click on the following link to confirm and manage your subcription: <a href=\"%s\">%s</a>. New subscriptions must be confirmed within 2 hours"), $url, NAME .' - ' . _("Validate subscription")); |
| 103 | + |
87 | 104 | } else { |
88 | 105 | if ( ! $subscriber->active ) { |
89 | 106 | // Subscriber is registered, but has not been activated yet... |
90 | 107 | $msg = sprintf(_("Thank you for registering to receive status updates via email.</br></br> Click on the following link to confirm and manage your subcription: <a href=\"%s\">%s</a>. New subscriptions must be confirmed within 2 hours"), $url, NAME .' - ' . _("Validate subscription")); |
91 | 108 | $subscriber->activate($subscriber->id); |
92 | | - |
| 109 | + |
93 | 110 | } else { |
94 | 111 | // subscriber is registered and active |
95 | | - $msg = sprintf(_("Click on the following link to update your existing subscription: <a href=\"%s\">%s</a>"), $url, NAME .' - ' . _("Manage subscription")); |
| 112 | + $msg = sprintf(_("Click on the following link to update your existing subscription: <a href=\"%s\">%s</a>"), $url, NAME .' - ' . _("Manage subscription")); |
96 | 113 | $subscriber->update($subscriber->id); |
97 | 114 | } |
98 | 115 | } |
|
101 | 118 | $message = _("You will receive an email shortly with an activation link. Please click on the link to activate and/or manage your subscription."); |
102 | 119 | $constellation->render_success($header, $message, true, WEB_URL, _('Go back')); |
103 | 120 |
|
104 | | - // Send email about new registration |
| 121 | + // Send email about new registration |
105 | 122 | $subject = _('Email subscription registered').' - '.NAME; |
106 | 123 | $mailer->send_mail($_POST['emailaddress'], $subject, $msg); |
107 | | - |
| 124 | + |
108 | 125 | $boolRegistered = true; |
109 | 126 | } |
110 | 127 |
|
|
116 | 133 | } |
117 | 134 | $strPostedEmail = (isset($_POST['emailaddress'])) ? $_POST['emailaddress'] : ""; |
118 | 135 | ?> |
119 | | - |
120 | | - |
| 136 | + |
| 137 | + |
121 | 138 | <form method="post" action="index.php?do=email_subscription&new=1" class="clearfix" enctype="multipart/form-data" > |
122 | 139 | <h3><?php echo _('Subscribe to get email notifications on status updates');?></h3> |
123 | 140 | <div class="form-group clearfix"> |
|
154 | 171 | // check if userid/token combo is valid, active or expired |
155 | 172 | $subscriber->typeID = 2; //EMAIL |
156 | 173 | if ( $subscriber->is_active_subscriber($_GET['token']) ) { |
157 | | - // forward user to subscriber list.... |
| 174 | + // forward user to subscriber list.... |
158 | 175 | $subscriber->set_logged_in(); |
159 | 176 | header('Location: subscriptions.php'); |
160 | 177 | exit; |
|
165 | 182 | $message = _("If you have recently subscribed, please make sure you activate the account within two hours of doing so. You are welcome to try and re-subscribe."); |
166 | 183 | $constellation->render_warning($header, $message, true, WEB_URL, _('Go back')); |
167 | 184 | } |
168 | | - |
169 | | - |
| 185 | + |
| 186 | + |
170 | 187 | } else if (isset($_GET['do']) && $_GET['do'] == 'unsubscribe') { |
171 | 188 | // Handle unsubscriptions |
172 | 189 | // TODO This function is universal and should probably live elsewhere?? |
173 | 190 | if (isset($_GET['token'])) { |
174 | | - $subscriber->typeID = (int) $_GET['type']; |
175 | | - |
| 191 | + $subscriber->typeID = (int) $_GET['type']; |
| 192 | + |
176 | 193 | if ( $subscriber->get_subscriber_by_token($_GET['token'])) { |
177 | 194 | $subscriber->delete($subscriber->id); |
178 | 195 | $subscriber->set_logged_off(); |
179 | 196 | Template :: render_header(_("Email Subscription")); |
180 | | - |
| 197 | + |
181 | 198 | $header = _("You have been unsubscribed from our system"); |
182 | 199 | $message = _("We are sorry to see you go. If you want to subscribe again at a later date please feel free to re-subscribe."); |
183 | | - $constellation->render_success($header, $message, true, WEB_URL, _('Go back')); |
184 | | - |
| 200 | + $constellation->render_success($header, $message, true, WEB_URL, _('Go back')); |
| 201 | + |
185 | 202 | } else { |
186 | 203 | // TODO Log token for troubleshooting ? |
187 | 204 | // Cannot find subscriber - show alert |
188 | 205 | Template :: render_header(_("Email Subscription")); |
189 | 206 | $header = _("We are unable to find any valid subscriber detail matching your submitted data!"); |
190 | | - $message = _("If you believe this to be an error, please contact the system admininistrator."); |
| 207 | + $message = _("If you believe this to be an error, please contact the system admininistrator."); |
191 | 208 | $constellation->render_warning($header, $message, true, WEB_URL, _('Go back')); |
192 | | - |
193 | | - // |
| 209 | + |
| 210 | + // |
194 | 211 | } |
195 | 212 | } else { |
196 | 213 | // TODO Log $_GET[] for troubleshooting ? |
197 | 214 | $header = _("We are unable to find any valid subscriber detail matching your submitted data!"); |
198 | | - $message = _("If you believe this to be an error, please contact the system admininistrator."); |
199 | | - $constellation->render_warning($header, $message, true, WEB_URL, _('Go back')); |
200 | | - } |
| 215 | + $message = _("If you believe this to be an error, please contact the system admininistrator."); |
| 216 | + $constellation->render_warning($header, $message, true, WEB_URL, _('Go back')); |
| 217 | + } |
201 | 218 | } |
202 | 219 | Template :: render_footer(); |
0 commit comments