From a6daf207244d38deec000773e28ae406b3b8db40 Mon Sep 17 00:00:00 2001 From: tim gavin Date: Sun, 30 Jan 2022 10:59:19 -0500 Subject: [PATCH] closes #135 --- README.md | 2 +- class.formr.php | 9 +++++++-- lib/wrappers/bulma.php | 34 +++++++++++++++++++++++----------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 50674a0..1278507 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Formr -Formr is a PHP micro-framework which installs easily and helps you build, layout and validate forms quickly, painlessly, and without all the complicated, messy overhead. +Formr is a ridiculously fast and easy PHP form builder, with support for Bootstrap and Bulma right out of the box! Find docs here: [http://formr.github.io](http://formr.github.io) diff --git a/class.formr.php b/class.formr.php index 7a4a057..d4f503e 100644 --- a/class.formr.php +++ b/class.formr.php @@ -3,7 +3,7 @@ namespace Formr; /** - * Formr (1.4.1) + * Formr (1.4.2) * * a php micro-framework to help you quickly build and validate web forms * @@ -4982,6 +4982,10 @@ public function unset_session() public function ok() { + if (isset($_POST['csrf_token']) && !isset($_SESSION['formr']['token'])) { + return false; + } + if (empty($this->errors)) { return true; } @@ -5138,6 +5142,7 @@ public function recaptcha_passed() 'response' => $_POST['formrToken'], 'remoteip' => $_SERVER['REMOTE_ADDR'] ], + CURLOPT_SSL_VERIFYPEER => false, CURLOPT_RETURNTRANSFER => true ]); $response = curl_exec($ch); @@ -5149,7 +5154,7 @@ public function recaptcha_passed() # convert the json encoded string to a php variable $result = json_decode($response, true); - if ($result['success'] == true && $result['score'] >= $this->recaptcha_score) { + if (!empty($result) && ($result['success'] == true) && ($result['score'] >= $this->recaptcha_score)) { return true; } diff --git a/lib/wrappers/bulma.php b/lib/wrappers/bulma.php index f340c32..968fcde 100644 --- a/lib/wrappers/bulma.php +++ b/lib/wrappers/bulma.php @@ -55,14 +55,14 @@ public function bulma($element = '', $data = '') $return .= '
' . $this->nl; } - $return .= ' ' . $this->nl; + $return .= '' . $this->nl; # show error message if ($this->formr->submitted() && $this->formr->in_errors($data['name']) && $this->formr->inline_errors) { - $return .= '

'.$this->formr->errors[$data['name']].'

'; + $return .= '

' . $this->formr->errors[$data['name']] . '

'; } # close the wrapper @@ -82,7 +82,13 @@ public function bulma($element = '', $data = '') $return .= '
' . $this->nl; } - $return .= $data['label'] ? '' : '' . $this->nl; + if ($this->formr->is_not_empty($data['label'])) { + $return .= '' . $this->nl; + } + $return .= '
' . $this->nl; $return .= '