BS Edge Installation Instructions

/includes/classes/recaptcha.php
/includes/languages/english/modules/content/forms/cm_forms_recaptcha.php
/includes/modules/content/forms/cm_forms_recaptcha.php
/includes/modules/content/forms/templates/recaptcha.php
// reCAPTCHA-2 for BS Edge define('MODULE_CONTENT_RECAPTCHA_ERROR', 'reCAPTCHA Security Box requires verification.');
ADD this just AFTER it:require('includes/application_top.php');
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
REPLACE it with this:if (isset($_GET['action']) && ($_GET['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken)) { $email_address = tep_db_prepare_input($_POST['email_address']); $password = tep_db_prepare_input($_POST['password']); // Check if email exists $customer_query = tep_db_query("select customers_id, customers_password from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' limit 1"); if (!tep_db_num_rows($customer_query)) { $error = true; } else { $customer = tep_db_fetch_array($customer_query); // Check that password is good if (!tep_validate_password($password, $customer['customers_password'])) { $error = true; } else { // set $login_customer_id globally and perform post login code in catalog/login.php $login_customer_id = (int)$customer['customers_id']; // migrate old hashed password to new phpass password if (tep_password_type($customer['customers_password']) != 'phpass') { tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . tep_encrypt_password($password) . "' where customers_id = '" . (int)$login_customer_id . "'"); } } } } if ($error == true) { $messageStack->add('login', MODULE_CONTENT_LOGIN_TEXT_LOGIN_ERROR); }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { if (isset($_GET['action']) && ($_GET['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken)) { $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $messageStack->add('login', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); $_POST['password'] = ""; } else { $email_address = tep_db_prepare_input($_POST['email_address']); $password = tep_db_prepare_input($_POST['password']); // Check if email exists $customer_query = tep_db_query("select customers_id, customers_password from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' limit 1"); if (!tep_db_num_rows($customer_query)) { $error = true; } else { $customer = tep_db_fetch_array($customer_query); // Check that password is good if (!tep_validate_password($password, $customer['customers_password'])) { $error = true; } else { // set $login_customer_id globally and perform post login code in catalog/login.php $login_customer_id = (int)$customer['customers_id']; // migrate old hashed password to new phpass password if (tep_password_type($customer['customers_password']) != 'phpass') { tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . tep_encrypt_password($password) . "' where customers_id = '" . (int)$login_customer_id . "'"); } } } } } } else { // reCAPTCHA module not enabled OR login page is not selected for it, use default validation code below if (isset($_GET['action']) && ($_GET['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken)) { $email_address = tep_db_prepare_input($_POST['email_address']); $password = tep_db_prepare_input($_POST['password']); // Check if email exists $customer_query = tep_db_query("select customers_id, customers_password from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' limit 1"); if (!tep_db_num_rows($customer_query)) { $error = true; } else { $customer = tep_db_fetch_array($customer_query); // Check that password is good if (!tep_validate_password($password, $customer['customers_password'])) { $error = true; } else { // set $login_customer_id globally and perform post login code in catalog/login.php $login_customer_id = (int)$customer['customers_id']; // migrate old hashed password to new phpass password if (tep_password_type($customer['customers_password']) != 'phpass') { tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . tep_encrypt_password($password) . "' where customers_id = '" . (int)$login_customer_id . "'"); } } } } } // reCAPTCHA-2 for BS Edge closing bracket if ($error == true) { $messageStack->add('login', MODULE_CONTENT_LOGIN_TEXT_LOGIN_ERROR); $_POST['password'] = ""; } // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
ADD just ABOVE it:if (ACCOUNT_GENDER == 'true') { if ( ($gender != 'm') && ($gender != 'f') ) { $error = true; $messageStack->add('create_account', ENTRY_GENDER_ERROR); } }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $error = true; $messageStack->add('create_account', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); $_POST['password'] = ""; $_POST['confirmation'] = ""; } } // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
b) FIND this code:// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
c) FIND this code:getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
ADD just ABOVE it:if (ACCOUNT_GENDER == 'true') { if ( ($gender != 'm') && ($gender != 'f') ) { $error = true; $messageStack->add('create_account', ENTRY_GENDER_ERROR); } }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { // reCAPTCHA module & account_pwa page enabled $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $error = true; $messageStack->add('create_account', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); } } // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
b) FIND this code:// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
c) FIND this code:getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
ADD just ABOVE it:if (ACCOUNT_GENDER == 'true') { if ( ($gender != 'm') && ($gender != 'f') ) { $error = true; $messageStack->add('account_edit', ENTRY_GENDER_ERROR); } }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { // reCAPTCHA module & account_edit page enabled $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $error = true; $messageStack->add('account_edit', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); } } // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
b) FIND this code:// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
c) FIND this code:getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
ADD just ABOVE it:if (strlen($password_new) < ENTRY_PASSWORD_MIN_LENGTH) { $error = true; $messageStack->add('account_password', ENTRY_PASSWORD_NEW_ERROR); } elseif ($password_new != $password_confirmation) { $error = true; $messageStack->add('account_password', ENTRY_PASSWORD_NEW_ERROR_NOT_MATCHING); }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { // reCAPTCHA module & account_password page enabled $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $error = true; $messageStack->add('account_password', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); $_POST['password_new'] = ""; $_POST['password_confirmation'] = ""; } } // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
b) FIND this code:// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
c) FIND this code:getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
REPLACE it with this:if (isset($_GET['action']) && ($_GET['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken)) { $email_address = tep_db_prepare_input($_POST['email_address']); $check_customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'"); if (tep_db_num_rows($check_customer_query)) { $check_customer = tep_db_fetch_array($check_customer_query); $actionRecorder = new actionRecorder('ar_reset_password', $check_customer['customers_id'], $email_address); if ($actionRecorder->canPerform()) { $actionRecorder->record(); $reset_key = tep_create_random_value(40); tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set password_reset_key = '" . tep_db_input($reset_key) . "', password_reset_date = now() where customers_info_id = '" . (int)$check_customer['customers_id'] . "'"); $reset_key_url = tep_href_link('password_reset.php', 'account=' . urlencode($email_address) . '&key=' . $reset_key, 'SSL', false); if ( strpos($reset_key_url, '&') !== false ) { $reset_key_url = str_replace('&', '&', $reset_key_url); } tep_mail($check_customer['customers_firstname'] . ' ' . $check_customer['customers_lastname'], $email_address, EMAIL_PASSWORD_RESET_SUBJECT, sprintf(EMAIL_PASSWORD_RESET_BODY, $reset_key_url), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $password_reset_initiated = true; } else { $actionRecorder->record(false); $messageStack->add('password_forgotten', sprintf(ERROR_ACTION_RECORDER, (defined('MODULE_ACTION_RECORDER_RESET_PASSWORD_MINUTES') ? (int)MODULE_ACTION_RECORDER_RESET_PASSWORD_MINUTES : 5))); } } else { $messageStack->add('password_forgotten', TEXT_NO_EMAIL_ADDRESS_FOUND); } }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { // reCAPTCHA module & password_forgotten page enabled if (isset($_GET['action']) && ($_GET['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken)) { $email_address = tep_db_prepare_input($_POST['email_address']); $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $messageStack->add('password_forgotten', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); } else { $check_customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'"); if (tep_db_num_rows($check_customer_query)) { $check_customer = tep_db_fetch_array($check_customer_query); $actionRecorder = new actionRecorder('ar_reset_password', $check_customer['customers_id'], $email_address); if ($actionRecorder->canPerform()) { $actionRecorder->record(); $reset_key = tep_create_random_value(40); tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set password_reset_key = '" . tep_db_input($reset_key) . "', password_reset_date = now() where customers_info_id = '" . (int)$check_customer['customers_id'] . "'"); $reset_key_url = tep_href_link('password_reset.php', 'account=' . urlencode($email_address) . '&key=' . $reset_key, 'SSL', false); if ( strpos($reset_key_url, '&') !== false ) { $reset_key_url = str_replace('&', '&', $reset_key_url); } tep_mail($check_customer['customers_firstname'] . ' ' . $check_customer['customers_lastname'], $email_address, EMAIL_PASSWORD_RESET_SUBJECT, sprintf(EMAIL_PASSWORD_RESET_BODY, $reset_key_url), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $password_reset_initiated = true; } else { $actionRecorder->record(false); $messageStack->add('password_forgotten', sprintf(ERROR_ACTION_RECORDER, (defined('MODULE_ACTION_RECORDER_RESET_PASSWORD_MINUTES') ? (int)MODULE_ACTION_RECORDER_RESET_PASSWORD_MINUTES : 5))); } } else { $messageStack->add('password_forgotten', TEXT_NO_EMAIL_ADDRESS_FOUND); } } // reCAPTCHA } } else { // reCAPTCHA module not enabled OR password_forgotten page is not selected for it, use default validation code below if (isset($_GET['action']) && ($_GET['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken)) { $email_address = tep_db_prepare_input($_POST['email_address']); $check_customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'"); if (tep_db_num_rows($check_customer_query)) { $check_customer = tep_db_fetch_array($check_customer_query); $actionRecorder = new actionRecorder('ar_reset_password', $check_customer['customers_id'], $email_address); if ($actionRecorder->canPerform()) { $actionRecorder->record(); $reset_key = tep_create_random_value(40); tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set password_reset_key = '" . tep_db_input($reset_key) . "', password_reset_date = now() where customers_info_id = '" . (int)$check_customer['customers_id'] . "'"); $reset_key_url = tep_href_link('password_reset.php', 'account=' . urlencode($email_address) . '&key=' . $reset_key, 'SSL', false); if ( strpos($reset_key_url, '&') !== false ) { $reset_key_url = str_replace('&', '&', $reset_key_url); } tep_mail($check_customer['customers_firstname'] . ' ' . $check_customer['customers_lastname'], $email_address, EMAIL_PASSWORD_RESET_SUBJECT, sprintf(EMAIL_PASSWORD_RESET_BODY, $reset_key_url), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $password_reset_initiated = true; } else { $actionRecorder->record(false); $messageStack->add('password_forgotten', sprintf(ERROR_ACTION_RECORDER, (defined('MODULE_ACTION_RECORDER_RESET_PASSWORD_MINUTES') ? (int)MODULE_ACTION_RECORDER_RESET_PASSWORD_MINUTES : 5))); } } else { $messageStack->add('password_forgotten', TEXT_NO_EMAIL_ADDRESS_FOUND); } } } // reCAPTCHA-2 for BS Edge closing bracket // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
b) FIND this code:// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
c) FIND this code:getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
ADD just ABOVE it:if (!tep_validate_email($email_address)) { $error = true; $messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR); }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { // reCAPTCHA module & contact_us page enabled $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $error = true; $messageStack->add('contact', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); } } // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
b) FIND this code:// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
c) FIND this code:getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
ADD just ABOVE it:if (empty($from_name)) { $error = true; $messageStack->add('friend', ERROR_FROM_NAME); }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { // reCAPTCHA module & tell_a_friend page enabled $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $error = true; $messageStack->add('friend', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); } } // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
b) FIND this code:// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
c) FIND this code:getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
ADD just ABOVE it:if (strlen($review) < REVIEW_TEXT_MIN_LENGTH) { $error = true; $messageStack->add('review', JS_REVIEW_TEXT); }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { // reCAPTCHA module & product_review_write page enabled $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $error = true; $messageStack->add('review', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); } } // reCAPTCHA-2 for BS Edge - End
ADD this just AFTER it:require('includes/application_top.php');
b) FIND this code:// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { require(DIR_WS_CLASSES . 'recaptcha.php'); } // reCAPTCHA-2 for BS Edge - End
ADD just ABOVE it:
c) FIND this code:getContent('forms'); } // reCAPTCHA-2 for BS Edge - End ?>
ADD just ABOVE it:if (strlen($review) < REVIEW_TEXT_MIN_LENGTH) { $error = true; $messageStack->add('review', JS_REVIEW_TEXT); }
// reCAPTCHA-2 for BS Edge - Start if (MODULE_CONTENT_RECAPTCHA_STATUS == 'True') { // reCAPTCHA module & product_review_write_pwa page enabled $recaptcha = $_POST['g-recaptcha-response']; $object = new Recaptcha(); $response = $object->verifyResponse($recaptcha); // Check if reCaptcha is correct if (isset($response['success']) and $response['success'] != true) { $error = true; $messageStack->add('review', MODULE_CONTENT_RECAPTCHA_ERROR . ' (Error: ' . $response['error-codes'] . ')'); } } // reCAPTCHA-2 for BS Edge - End
1) Log into your admin panel and go to Modules > Content
2) Click on the button at the top right called Install Module
3) Select the reCAPTCHA Form Validation module from the list
4) Install the module by clicking the Install Module button on the right side of the screen
You'll need to enter & save your Public and Private keys. If you have not already registered with Google reCAPTCHA, you'll need to go to the following link and register. The Google reCAPTCHA service is free.
https://www.google.com/recaptcha/admin/
You can now configure your BS Edge reCAPTCHA module as you want based on available options.