Hello everyone and welcome to my modest contribution,
FEC is great isnt it!
Get it here
http://www.zen-cart.com/index.php?ma...+easy+checkout
It offers many neat and necessary features one of them being Easy Sign up and login.
I also like the CAPTCHA module
Get it here
http://www.zen-cart.com/index.php?ma...roducts_id=325
But what about making both work together on the account creation/login page?
They dont work together out the box, if fact they dont really get along.
All I did was merged the files and I would like to share with you how to do this so that you dont have to have the hassle of reinventing the wheel.
As far as I know there is no such contribution if you know of such please let me know.
Ok down to work...
Download and install both add-ons follow the instructions carefully and make sure that the files go EXACTLY where they supposed to.
on FEC you will see a "classic" subfolders change that to your MY_TEMPLATE name.
first we need to fix CAPTCHA because it doesnt work out the box for the account creation page even with the zen cart defaults.
Go to /include/modules/MY_TEMPLATE/create_account.php
Change this code:
to thisPHP Code:<?php
if (strstr($_SERVER['REQUEST_URI'],'create_account') && CREATE_ACCOUNT_VALIDATION == 'true' || strstr($_SERVER['REQUEST_URI'],'login') && LOGIN_VALIDATION == 'true') {
?>
ALSO find this codePHP Code:<?php
if (strstr($_SERVER['REQUEST_URI'],'create_account') && CREATE_ACCOUNT_VALIDATION == 'true' || strstr($_SERVER['REQUEST_URI'],'login') && CREATE_ACCOUNT_VALIDATION == 'true') {
?>
Insert JUST AFTER IT this codePHP Code:$password = zen_db_prepare_input($_POST['password']);
$confirmation = zen_db_prepare_input($_POST['confirmation']);
AND ALSO find this codePHP Code:if (ACCOUNT_VALIDATION == 'true' && CREATE_ACCOUNT_VALIDATION == 'true') {
$antirobotreg = zen_db_prepare_input($_POST['antirobotreg']);
}
$error = false;
Insert JUST BEFORE IT this codePHP Code:if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) {
$error = true;
$messageStack->add_session('login', ENTRY_PASSWORD_ERROR);
} elseif ($password != $confirmation) {
$error = true;
$messageStack->add_session('login', ENTRY_PASSWORD_ERROR_NOT_MATCHING);
}
Finally findPHP Code:if (ACCOUNT_VALIDATION == 'true' && CREATE_ACCOUNT_VALIDATION == 'true') {
$sql = "SELECT * FROM " . TABLE_ANTI_ROBOT_REGISTRATION . " WHERE session_id = '" . zen_session_id() . "' LIMIT 1";
if( !$result = $db->Execute($sql) ) {
$error = true;
$entry_antirobotreg_error = true;
$text_antirobotreg_error = ERROR_VALIDATION_1;
$messageStack->add('create_account', ERROR_VALIDATION_1);
} else {
$entry_antirobotreg_error = false;
$antirobotrow = $db->Execute($sql);
if (( strtolower($_POST['antirobotreg']) != $antirobotrow->fields['reg_key'] ) or ($antirobotrow->fields['reg_key'] =='')) {
$error = true;
$entry_antirobotreg_error = true;
$text_antirobotreg_error = ERROR_VALIDATION_2;
$messageStack->add('create_account', ERROR_VALIDATION_2);
} else {
$sql = "DELETE FROM " . TABLE_ANTI_ROBOT_REGISTRATION . " WHERE session_id = '" . zen_session_id() . "'";
if( !$result = $db->Execute($sql) )
{
$error = true;
$entry_antirobotreg_error = true;
$text_antirobotreg_error = ERROR_VALIDATION_3;
$messageStack->add('create_account', ERROR_VALIDATION_3);
} else {
$sql = "OPTIMIZE TABLE " . TABLE_ANTI_ROBOT_REGISTRATION . "";
if( !$result = $db->Execute($sql) )
{
$error = true;
$entry_antirobotreg_error = true;
$text_antirobotreg_error = ERROR_VALIDATION_4;
$messageStack->add('create_account', ERROR_VALIDATION_4);
} else {
$entry_antirobotreg_error = false;
}
}
}
}
if (strlen($antirobotreg) <> ENTRY_VALIDATION_LENGTH) {
$error = true;
$entry_antirobotreg_error = true;
} else {
$entry_antirobotreg_error = false;
}
}
Change to:PHP Code:if ($error == true) {
// hook notifier class
$zco_notifier->notify('NOTIFY_FAILURE_DURING_CREATE_ACCOUNT');
// redirect back to login page
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
} else {
$sql_data_array = array('customers_firstname' => $firstname,
'customers_lastname' => $lastname,
'customers_email_address' => $email_address,
'customers_nick' => $nick,
'customers_telephone' => $telephone,
'customers_fax' => $fax,
'customers_newsletter' => (int)$newsletter,
'customers_email_format' => $email_format,
'customers_default_address_id' => 0,
'customers_password' => zen_encrypt_password($password),
'customers_authorization' => (int)CUSTOMERS_APPROVAL_AUTHORIZATION
);
Thats that with the modules files!PHP Code:if ($error == true) {
// hook notifier class
$zco_notifier->notify('NOTIFY_FAILURE_DURING_CREATE_ACCOUNT');
} else {
$sql_data_array = array('customers_firstname' => $firstname,
'customers_lastname' => $lastname,
'customers_email_address' => $email_address,
'customers_nick' => $nick,
'customers_telephone' => $telephone,
'customers_fax' => $fax,
'customers_newsletter' => (int)$newsletter,
'customers_email_format' => $email_format,
'customers_default_address_id' => 0,
'customers_password' => zen_encrypt_password($password),
'customers_authorization' => (int)CUSTOMERS_APPROVAL_AUTHORIZATION
);
Now go to your template files
/includes/templates/MY_TEMPLATE/templates/tpl_modules_create_account.php
Find this code:
INSERT RIGHT AFTER IT:PHP Code:<?php echo zen_draw_radio_field('email_format', 'HTML', ($email_format == 'HTML' ? true : false),'id="email-format-html"') . '<label class="radioButtonLabel" for="email-format-html">' . ENTRY_EMAIL_HTML_DISPLAY . '</label>' . zen_draw_radio_field('email_format', 'TEXT', ($email_format == 'TEXT' ? true : false), 'id="email-format-text"') . '<label class="radioButtonLabel" for="email-format-text">' . ENTRY_EMAIL_TEXT_DISPLAY . '</label>'; ?>
<br class="clearBoth" />
</fieldset>
THATS IT! youre done!PHP Code:<?php
if (ACCOUNT_VALIDATION == 'true') {
?>
<?php
if (strstr($_SERVER['REQUEST_URI'],'create_account') && CREATE_ACCOUNT_VALIDATION == 'true' || strstr($_SERVER['REQUEST_URI'],'login') && CREATE_ACCOUNT_VALIDATION == 'true') {
?>
<?php
if ($is_read_only == false || (strstr($_SERVER['REQUEST_URI'],'create_account')) || (strstr($_SERVER['REQUEST_URI'],'login'))) {
$sql = "DELETE FROM " . TABLE_ANTI_ROBOT_REGISTRATION . " WHERE timestamp < '" . (time() - 3600) . "' OR session_id = '" . zen_session_id() . "'";
if( !$result = $db->Execute($sql) ) { die('Could not delete validation key'); }
$reg_key = generate_captcha_code();
$sql = "INSERT INTO ". TABLE_ANTI_ROBOT_REGISTRATION . " VALUES ('" . zen_session_id() . "', '" . $reg_key . "', '" . time() . "')";
if( !$result = $db->Execute($sql) ) { die('Could not check registration information'); }
?>
<fieldset>
<legend><?php echo CATEGORY_ANTIROBOTREG; ?></legend>
<label class="inputLabel" for="antirobotreg"><?php echo ENTRY_ANTIROBOTREG ?></label>
<?php
$validation_images = '';
for($i = 0; $i < ENTRY_VALIDATION_LENGTH; $i++)
{
$parse_image = 'validation/validation_' . $reg_key{$i} . '.gif';
$parse_image_alt = $reg_key{$i};
$validation_images .= zen_image(DIR_WS_IMAGES . $parse_image, $parse_image_alt);
}
echo '<div class="centered">';
echo $validation_images . '<br />';
echo '</div>';
?>
<?php echo zen_draw_input_field('antirobotreg','', 'id="antirobotreg"') . (zen_not_null(ENTRY_ANTIROBOTREG) ? '<span class="alert">' . ENTRY_ANTIROBOTREG_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
<?php
}
?>
<?php
}
?>
<?php
}
?>



