From 64e3db16f33bec4520459727ceebe32af7d01a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=81Z=C3=81R=20Imre=20AI=20Agent?= Date: Thu, 16 Jul 2026 11:39:03 +0200 Subject: [PATCH] feat(cadline): add com_users Cadline additions (recaptcha, easyprofile) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cadline/JSN additions to com_users: recaptchalib.php (anti-spam), easyprofile.php views (JSN EasyProfile) — only-in-live files not caught by the core-override diff. Signed-off-by: LÁZÁR Imre Assisted-by: claude-code@claude-opus-4-8 --- .../com_users/controllers/recaptchalib.php | 143 ++++++++++++++++++ .../views/profile/tmpl/easyprofile.php | 76 ++++++++++ .../views/registration/tmpl/easyprofile.php | 75 +++++++++ 3 files changed, 294 insertions(+) create mode 100644 cadline/docroot/components/com_users/controllers/recaptchalib.php create mode 100644 cadline/docroot/components/com_users/views/profile/tmpl/easyprofile.php create mode 100644 cadline/docroot/components/com_users/views/registration/tmpl/easyprofile.php diff --git a/cadline/docroot/components/com_users/controllers/recaptchalib.php b/cadline/docroot/components/com_users/controllers/recaptchalib.php new file mode 100644 index 00000000..a890cbd2 --- /dev/null +++ b/cadline/docroot/components/com_users/controllers/recaptchalib.php @@ -0,0 +1,143 @@ +" . self::$_signupUrl . ""); + } + $this->_secret=$secret; + } + + /** + * Encodes the given data into a query string format. + * + * @param array $data array of string elements to be encoded. + * + * @return string - encoded request. + */ + private function _encodeQS($data) + { + $req = ""; + foreach ($data as $key => $value) { + $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; + } + + // Cut the last '&' + $req=substr($req, 0, strlen($req)-1); + return $req; + } + + /** + * Submits an HTTP GET to a reCAPTCHA server. + * + * @param string $path url path to recaptcha server. + * @param array $data array of parameters to be sent. + * + * @return array response + */ + private function _submitHTTPGet($path, $data) + { + $req = $this->_encodeQS($data); + $response = file_get_contents($path . $req); + return $response; + } + + /** + * Calls the reCAPTCHA siteverify API to verify whether the user passes + * CAPTCHA test. + * + * @param string $remoteIp IP address of end user. + * @param string $response response string from recaptcha verification. + * + * @return ReCaptchaResponse + */ + public function verifyResponse($remoteIp, $response) + { + // Discard empty solution submissions + if ($response == null || strlen($response) == 0) { + $recaptchaResponse = new ReCaptchaResponse(); + $recaptchaResponse->success = false; + $recaptchaResponse->errorCodes = 'missing-input'; + return $recaptchaResponse; + } + + $getResponse = $this->_submitHttpGet( + self::$_siteVerifyUrl, + array ( + 'secret' => $this->_secret, + 'remoteip' => $remoteIp, + 'v' => self::$_version, + 'response' => $response + ) + ); + $answers = json_decode($getResponse, true); + $recaptchaResponse = new ReCaptchaResponse(); + + if (trim($answers ['success']) == true) { + $recaptchaResponse->success = true; + } else { + $recaptchaResponse->success = false; + $recaptchaResponse->errorCodes = $answers [error-codes]; + } + + if ($_SERVER['REMOTE_ADDR'] == '85.66.171.33') { + var_dump($recaptchaResponse); + die(); + } + + return $recaptchaResponse; + } +} diff --git a/cadline/docroot/components/com_users/views/profile/tmpl/easyprofile.php b/cadline/docroot/components/com_users/views/profile/tmpl/easyprofile.php new file mode 100644 index 00000000..426e94c5 --- /dev/null +++ b/cadline/docroot/components/com_users/views/profile/tmpl/easyprofile.php @@ -0,0 +1,76 @@ +form, $this->data); + +include( JPATH_SITE . '/components/com_users/views/profile/tmpl/edit.php'); + +$config = JComponentHelper::getParams('com_jsn'); +$layout_width=$config->get('layout_width','full'); +if( $layout_width == 'full' ) $max_width = 'none'; +else $max_width = $config->get('layout_maxwidth','500'); +$layout=$config->get('layout_form','horizontal'); + +$session = JFactory::getSession(); +$profile_menuid = $session->get('jsn_profile_item_id_'.(JFactory::getApplication()->input->get('user_id',JFactory::getUser()->id)),false); +if($profile_menuid) $Itemid = '&Itemid='.$profile_menuid; +else $Itemid = ''; +?> + + \ No newline at end of file diff --git a/cadline/docroot/components/com_users/views/registration/tmpl/easyprofile.php b/cadline/docroot/components/com_users/views/registration/tmpl/easyprofile.php new file mode 100644 index 00000000..a781d3e2 --- /dev/null +++ b/cadline/docroot/components/com_users/views/registration/tmpl/easyprofile.php @@ -0,0 +1,75 @@ +get('layout_width','full'); +if( $layout_width == 'full' ) $max_width = 'none'; +else $max_width = $config->get('layout_maxwidth','500'); +$layout=$config->get('layout_form','horizontal'); +$lang = JFactory::getLanguage(); +$result = $lang->getTag(); + +?> + + \ No newline at end of file