diff --git a/common_config.php b/common_config.php
index 007dc6d..cff8859 100644
--- a/common_config.php
+++ b/common_config.php
@@ -1,23 +1,4 @@
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
'._('Invalid onion address!').'
'; echo ''.sprintf(_('A valid address looks like this: %s'), 'http://danielas3rtn54uwmofdo3x2bsdifr47huasnmbgqzfrec5ubupvtpid.onion') .'
'; }else{ - if(!isset($_REQUEST['challenge'])){ - send_error(_('Error: Wrong captcha')); - } - $stmt=$db->prepare('SELECT code FROM ' . PREFIX . 'captcha WHERE id=?;'); - $stmt->execute([$_REQUEST['challenge']]); - $stmt->bindColumn(1, $code); - if(!$stmt->fetch(PDO::FETCH_BOUND)){ - send_error(_('Error: Captcha expired')); - } - $time=time(); - $stmt=$db->prepare('DELETE FROM ' . PREFIX . 'captcha WHERE id=? OR time;'); - $stmt->execute([$_REQUEST['challenge'], $time-3600]); - if($_REQUEST['captcha']!==$code){ - if(strrev($_REQUEST['captcha'])!==$code){ - send_error(_('Error: Wrong captcha')); + if(CAPTCHA !== 0) { + if ( ! isset( $_REQUEST[ 'challenge' ] ) ) { + send_error( _( 'Error: Wrong captcha' ) ); + } + $stmt = $db->prepare( 'SELECT code FROM ' . PREFIX . 'captcha WHERE id=?;' ); + $stmt->execute( [ $_REQUEST[ 'challenge' ] ] ); + $stmt->bindColumn( 1, $code ); + if ( ! $stmt->fetch( PDO::FETCH_BOUND ) ) { + send_error( _( 'Error: Captcha expired' ) ); + } + $time = time(); + $stmt = $db->prepare( 'DELETE FROM ' . PREFIX . 'captcha WHERE id=? OR time;' ); + $stmt->execute( [ $_REQUEST[ 'challenge' ], $time - 3600 ] ); + if ( $_REQUEST[ 'captcha' ] !== $code ) { + if ( strrev( $_REQUEST[ 'captcha' ] ) !== $code ) { + send_error( _( 'Error: Wrong captcha' ) ); + } } } $addr=strtolower($addr[4]); @@ -489,8 +491,7 @@ function get_pagination(int $category, int $pages) : string { function send_captcha(): void { global $db; - $difficulty=1; - if($difficulty===0 || !extension_loaded('gd')){ + if(CAPTCHA === 0 || !extension_loaded('gd')){ return; } $captchachars='ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789'; @@ -504,28 +505,80 @@ function send_captcha(): void $stmt=$db->prepare('INSERT INTO ' . PREFIX . 'captcha (id, time, code) VALUES (?, ?, ?);'); $stmt->execute([$randid, $time, $code]); echo '