Add captcha script only if captcha length > 0
Change-Id: Ia1afe32cc186637de20ec18f00183c3309641598
diff --git a/index.php b/index.php
index ba273e4..cfc1785 100755
--- a/index.php
+++ b/index.php
@@ -13,6 +13,7 @@
use Monolog\Handler\StreamHandler;
use Monolog\Handler\RotatingFileHandler;
use \User as User;
+include $TEMPLATE . "strings.php";
$log = new Logger('signup');
$log->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/signup.log', 0, Logger::DEBUG));
@@ -36,6 +37,20 @@
$TEMPLATE = template_path();
+function send_welcome_email(User $user)
+{
+ global $SMTP, $SERVICE_ACRONYM, $WELCOME_TEMPLATE, $TEMPLATE;
+ $TEMPLATE = template_path();
+ include $TEMPLATE . "email.php";
+ $url = "";
+
+ send_mail($user->email, $SMTP, (object) [
+ "subject" => $WELCOME_TEMPLATE->subject,
+ "text" => replace_all_user_variables($WELCOME_TEMPLATE->text, $user, $url),
+ "html" => replace_all_user_variables($WELCOME_TEMPLATE->html, $user, $url)
+ ]);
+}
+
function send_confirmation_email(string $mail, object $smtp, string $url, User $user)
{
include 'config.php';
@@ -65,31 +80,34 @@
function reload_captcha_script()
{
include 'config.php';
- $TEMPLATE = template_path();
- include $TEMPLATE . "strings.php";
- echo '
- <script>
- const reload_captcha = async (e) => {
- var cont = document.getElementById("reload_captcha");
- cont.innerHTML = "<div class=\'spinner-border text-info\' role=\'status\'><span class=\'sr-only\'>' . $STRINGS->reloading_captcha . '</span></div>";
- var img = document.getElementById("captcha")
- var url = "' . $BASE_URL . '/captcha.php?token=' . $_SESSION["captcha_token"] . '"
- await fetch(url, { cache: "reload", mode: "no-cors" })
- .then(() => {
- img.src = url+"&t=" + new Date().getTime();
- setTimeout( () => {
- cont.innerHTML = "<button id=\'reload\' class=\'btn btn-outline-info\' type=\'button\'> <span class=\'glyphicon glyphicon-refresh\' aria-hidden=\'true\'></span></button>";
- bindButton()
- }, 500);
- })
- }
- function bindButton(){
- var button = document.getElementById("reload");
- button.addEventListener("click", reload_captcha)
- }
- bindButton()
- </script>
- ';
+
+ if ($CAPTCHA_LENGTH > 0) {
+ $TEMPLATE = template_path();
+ include $TEMPLATE . "strings.php";
+ echo '
+ <script>
+ const reload_captcha = async (e) => {
+ var cont = document.getElementById("reload_captcha");
+ cont.innerHTML = "<div class=\'spinner-border text-info\' role=\'status\'><span class=\'sr-only\'>' . $STRINGS->reloading_captcha . '</span></div>";
+ var img = document.getElementById("captcha")
+ var url = "' . $BASE_URL . '/captcha.php?token=' . $_SESSION["captcha_token"] . '"
+ await fetch(url, { cache: "reload", mode: "no-cors" })
+ .then(() => {
+ img.src = url+"&t=" + new Date().getTime();
+ setTimeout( () => {
+ cont.innerHTML = "<button id=\'reload\' class=\'btn btn-outline-info\' type=\'button\'> <span class=\'glyphicon glyphicon-refresh\' aria-hidden=\'true\'></span></button>";
+ bindButton()
+ }, 500);
+ })
+ }
+ function bindButton(){
+ var button = document.getElementById("reload");
+ button.addEventListener("click", reload_captcha)
+ }
+ bindButton()
+ </script>
+ ';
+ }
}
function register_page($error = false)