From 740f6e260a55cd33f014b3a8686d0c29173cece0 Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Wed, 14 Jul 2021 18:02:39 -0400 Subject: [PATCH] Fix CAPTCHA --- includes/captcha.php | 7 +------ index.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/includes/captcha.php b/includes/captcha.php index f5037f7..a510ba3 100644 --- a/includes/captcha.php +++ b/includes/captcha.php @@ -63,7 +63,7 @@ function captcha($color, $mode, $mul, $allowed) { } // Overwrite defaults with custom config values - if (is_array($config)) { + if (!empty($config) && is_array($config)) { foreach ($config as $key => $value) $captcha_config[$key] = $value; } @@ -82,8 +82,6 @@ function captcha($color, $mode, $mul, $allowed) { if ($captcha_config['max_font_size'] < $captcha_config['min_font_size']) $captcha_config['max_font_size'] = $captcha_config['min_font_size']; - // Use milliseconds instead of seconds - srand(microtime() * 100); // Generate CAPTCHA code if not set by user if (empty($captcha_config['code'])) { @@ -136,9 +134,6 @@ if (isset($_GET['_CAPTCHA'])) { if (!$captcha_config) exit(); - // Use milliseconds instead of seconds - srand(microtime() * 100); - // Pick random background, get info, and start captcha $background = $captcha_config['backgrounds'][rand(0, count($captcha_config['backgrounds']) - 1)]; list($bg_width, $bg_height, $bg_type, $bg_attr) = getimagesize($background); diff --git a/index.php b/index.php index aba0c75..270309e 100644 --- a/index.php +++ b/index.php @@ -142,7 +142,7 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') { updatePageViews($conn); // POST Handler -if ($_SERVER['REQUEST_METHOD'] == 'POST') { +if ($_SERVER['REQUEST_METHOD'] === 'POST') { $error = validatePasteFields(); if ($error !== null) {