Jump to content
Sign in to follow this  
greysun

AutoLogon 0.92 BETA SQL error

Recommended Posts

When I try to insert a new row under category I get the following error

anyone know why?

 

Error

SQL-query :

 

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES ('226', 'Allow AutoLogon', 'ALLOW_AUTOLOGON', '0', 'Allow registered users to save their login-info into a cookie so they are automatically logged in upon return to the shop', '1', '15', '2002-09-25 05:40:40', '2002-09-25 05:40:40', NULL, NULL);

 

MySQL said:

 

 

Duplicate entry '226' for key 1

Share this post


Link to post
Share on other sites

You get this error because I made a mistake in the contrib... :?

 

Try this instead:

 

INSERT INTO `configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES ('Allow AutoLogon', 'ALLOW_AUTOLOGON', '0', 'Allow registered users to save their login-info into a cookie so they are automatically logged in upon return to the shop', '1', '15', '2002-09-25 05:40:40', '2002-09-25 05:40:40', NULL, NULL);

 

 

Sorry,

 

Marcel


Greetings from Marcel

|Current version|Documentation|Contributions|

Share this post


Link to post
Share on other sites

Ok, I found out that there was already an entry 226 related to autologin so I guess it must have entered correctly the first time.

 

Anyway that fixes that but now I am getting a parse error in my login.php

 

Below is a cut and paste of the area that is causing the erroe. Can anyone tell me why I am getting the error

 

<td class="main"><b><?php echo ENTRY_EMAIL_ADDRESS; ?></b></td>

<td class="main"><?php echo tep_draw_input_field('email_address'); ?></td>

</tr>

<tr>

<td class="main"><b><?php echo ENTRY_PASSWORD; ?></b></td>

<td class="main"><?php echo tep_draw_password_field('password'); ?></td>

</tr>

<?php

// HMCS: Begin Autologon***********************************

if(ALLOW_AUTOLOGON != '0') {

?>

<tr>

<td>

</td>

<td align="left" class="smalltext"><?php echo tep_draw_checkbox_field('remember_me','on', (($password == '') ? false : true)) . ' ' . ENTRY_REMEMBER_ME; ?></td>

</tr>

<?php }

// HMCS: Begin Autologon***************************************

 

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="smallText" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_PASSWORD_FORGOTTEN, '', 'SSL') . '">' . TEXT_PASSWORD_FORGOTTEN . '</a>'; ?></td>

</tr>

Share this post


Link to post
Share on other sites

Something must has gone wrong in applying the changes:

 

<?php }

// HMCS: Begin Autologon***************************************

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="smallText" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_PASSWORD_FORGOTTEN, '', 'SSL') . '">' . TEXT_PASSWORD_FORGOTTEN . '</a>'; ?></td>

</tr>

 

 

I marked the corrections in bold.

 

Marcel


Greetings from Marcel

|Current version|Documentation|Contributions|

Share this post


Link to post
Share on other sites

I had tried that in the past and it just ignores it and loads the page as normal. I am correct in saying that when the script is working it should add a check box or something that says REMEMBER ME or something similar

 

I made the changes you mentioned but for some reason it still just ignores it all together.

 

Below is my entire login files.

 

Can anyone see anything out of place?

 

<?php

/*

$Id: login.php,v 1.70 2002/08/06 12:11:57 dgw_ Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

if ($HTTP_GET_VARS['action'] == 'process') {

$email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);

$password = tep_db_prepare_input($HTTP_POST_VARS['password']);

 

// Check if email exists

$check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");

if (!tep_db_num_rows($check_customer_query)) {

$HTTP_GET_VARS['login'] = 'fail';

} else {

$check_customer = tep_db_fetch_array($check_customer_query);

// Check that password is good

if (!validate_password($password, $check_customer['customers_password'])) {

$HTTP_GET_VARS['login'] = 'fail';

} else {

$check_country_query = tep_db_query("select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $check_customer['customers_id'] . "' and address_book_id = '1'");

$check_country = tep_db_fetch_array($check_country_query);

 

$customer_id = $check_customer['customers_id'];

$customer_default_address_id = $check_customer['customers_default_address_id'];

$customer_first_name = $check_customer['customers_firstname'];

$customer_country_id = $check_country['entry_country_id'];

$customer_zone_id = $check_country['entry_zone_id'];

tep_session_register('customer_id');

tep_session_register('customer_default_address_id');

tep_session_register('customer_first_name');

tep_session_register('customer_country_id');

tep_session_register('customer_zone_id');

 

setcookie('email_address', $email_address, time()+2592000, substr(DIR_WS_CATALOG, 0, -1));

setcookie('first_name', $customer_first_name, time()+2592000, substr(DIR_WS_CATALOG, 0, -1));

// HMCS: Begin Autologon **************************

if ($HTTP_POST_VARS['remember_me'] == '') {

setcookie("password", "", time() - 3600, substr(DIR_WS_CATALOG, 0, -1)); // Delete password cookie

} else {

Switch (ALLOW_AUTOLOGON) {

case '1': // Secure Link only

setcookie('password', $password, time()+ (365 * 24 * 3600), substr(DIR_WS_CATALOG, 0, -1), '', 1);

break;

case '2': // All links allowed, should not be used in production-environment

setcookie('password', $password, time()+ (365 * 24 * 3600), substr(DIR_WS_CATALOG, 0, -1));

break;

default: // Autologon disabled

setcookie('password', '', time() - 3600, substr(DIR_WS_CATALOG, 0, -1));

break;

}

}

// HMCS: End Autologon *****************************

 

$date_now = date('Ymd');

tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = now(), customers_info_number_of_logons = customers_info_number_of_logons+1 where customers_info_id = '" . $customer_id . "'");

 

// restore cart contents

$cart->restore_contents();

 

if (sizeof($navigation->snapshot) > 0) {

$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);

$navigation->clear_snapshot();

tep_redirect($origin_href);

} else {

tep_redirect(tep_href_link(FILENAME_DEFAULT));

}

}

}

}

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_LOGIN);

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_LOGIN, '', 'SSL'));

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<script language="javascript"><!--

function session_win() {

window.open("<?php echo FILENAME_INFO_SHOPPING_CART; ?>","info_shopping_cart","height=460,width=430,toolbar=no,statusbar=no,scrollbars=yes").focus();

}

//--></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="3" cellpadding="3">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td rowspan="2" class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_login.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

if ($HTTP_GET_VARS['login'] == 'fail') {

$info_message = TEXT_LOGIN_ERROR;

} elseif ($cart->count_contents()) {

$info_message = TEXT_VISITORS_CART;

}

 

if (isset($info_message)) {

?>

<tr>

<td class="smallText"><?php echo $info_message; ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

?>

<tr>

<td><?php echo tep_draw_form('login', tep_href_link(FILENAME_LOGIN, 'action=process', 'SSL')); ?><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="main" width="50%" valign="top"><b><?php echo HEADING_NEW_CUSTOMER; ?></b></td>

<td class="main" width="50%" valign="top"><b><?php echo HEADING_RETURNING_CUSTOMER; ?></b></td>

</tr>

<tr>

<td width="50%" height="100%" valign="top"><table border="0" width="100%" height="100%" cellspacing="0" cellpadding="1" class="infoBox">

<tr>

<td><table border="0" width="100%" height="100%" cellspacing="0" cellpadding="2" class="infoBoxContents">

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php echo TEXT_NEW_CUSTOMER . '<br><br>' . TEXT_NEW_CUSTOMER_INTRODUCTION; ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

<td width="50%" height="100%" valign="top"><table border="0" width="100%" height="100%" cellspacing="0" cellpadding="1" class="infoBox">

<tr>

<td><table border="0" width="100%" height="100%" cellspacing="0" cellpadding="2" class="infoBoxContents"

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="main" colspan="2"><?php echo TEXT_RETURNING_CUSTOMER; ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="main"><b><?php echo ENTRY_EMAIL_ADDRESS; ?></b></td>

<td class="main"><?php echo tep_draw_input_field('email_address'); ?></td>

</tr>

<tr>

<td class="main"><b><?php echo ENTRY_PASSWORD; ?></b></td>

<td class="main"><?php echo tep_draw_password_field('password'); ?></td>

</tr>

<?php

// HMCS: Begin Autologon *********************************

if(ALLOW_AUTOLOGON != '0') {

?>

<tr>

<td>

</td>

<td align="left" class="smalltext"><?php echo tep_draw_checkbox_field('remember_me','on', (($password == '') ? false : true)) . ' ' . ENTRY_REMEMBER_ME; ?></td>

</tr>

<?php }

// HMCS: Begin Autologon **********************************

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="smallText" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_PASSWORD_FORGOTTEN, '', 'SSL') . '">' . TEXT_PASSWORD_FORGOTTEN . '</a>'; ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

<tr>

<td width="50%" align="right" valign="top"><?php echo '<a href="' . tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>

<td width="50%" align="right" valign="top"><?php echo tep_image_submit('button_login.gif', IMAGE_BUTTON_LOGIN); ?></td>

</tr>

</table></form></td>

</tr>

</table></td>

<!-- body_text_eof //-->

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

</table></td>

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Share this post


Link to post
Share on other sites

Sorry for my late response, I've been very busy...

 

Your login.php looks ok to me and, yes, you should see a checkbox in the login form.

 

I have two questions:

 

a. Did you activate the contribution in Adminmy storeallow autologon?

b. Do you have an URL to your shop for me, so I can check the generated HTML?

 

M@rcel


Greetings from Marcel

|Current version|Documentation|Contributions|

Share this post


Link to post
Share on other sites

Ok I didnt have it enabled so that fixes that problem but now I have a new problem. When I log in using the remember me function and then close the brower and come back to the cart it doesnt remember me. I tried setting it to 1 and 2 in admin and neither works.

 

to get to the cart go to

 

www.bullislandmerchandising.com/catalog

 

One thing I want to mention that may or may not make a difference is that when it first started working it displayed the text ENTRY_REMEMBER_ME beside the check box instead of Remember Me!

 

I had to define the Remember Me in Login.php

 

ANy idea what might be happening now?

Share this post


Link to post
Share on other sites

The missing text is fixed by submitting a new version ( 0.93 Beta ) to the contribution area.

 

http://www.oscommerce.com/downloads.php/co...ions,531/type,3.

 

I tried to create an account on your site, but it took ages to complete, so I stopped it. Can you create a testaccount for me and mail me the credentials?

 

Marcel


Greetings from Marcel

|Current version|Documentation|Contributions|

Share this post


Link to post
Share on other sites
Ok I didnt have it enabled so that fixes that problem but now I have a new problem. When I log in using the remember me function and then close the brower and come back to the cart it doesnt remember me. I tried setting it to 1 and 2 in admin and neither works.

 

to get to the cart go to

 

www.bullislandmerchandising.com/catalog

 

One thing I want to mention that may or may not make a difference is that when it first started working it displayed the text ENTRY_REMEMBER_ME beside the check box instead of Remember Me!

 

I had to define the Remember Me in Login.php

 

ANy idea what might be happening now?

 

I have installed this contribution and am having the following problems:

 

1. My cart is not remembering me when I come back to the store. I cannot find where a cookie has been written to my computer. I did check admin to make sure I have the autologon option enabled.

 

2. Beside the "Remember Me" checkbox, I also had "ENTRY_REMEMBER_ME". The problem is not that there were missing pages from the V.092 Auto Logon Beta contribution. The problem is that the text for it is not defined.

 

I fixed this by going to catalog/includes/languages/english.php and adding this line:

 

define('ENTRY_REMEMBER_ME', 'Save Password');

 

(I changed mine to "Save Password".)

 

You will need to add the line above to each of the language pages you use, (i.e. english.php, german.php, spanish.php, etc.)

 

3. According to the README.txt instructions that came with this contribution:

 

A "read me first" hyperlink is available next to the new checkbox in the login-form.

 

As you can see by the code below, there is no link.

 

<?php

// HMCS: Begin Autologon **********************************************************

if(ALLOW_AUTOLOGON != '0') {

?>

<tr>

<td> </td>

<td align="left" class="smalltext"><?php echo tep_draw_checkbox_field('remember_me','on', (($password == '') ? false : true)) . ENTRY_REMEMBER_ME; ?></td>

</tr>

<?php }

// HMCS: Begin Autologon **********************************************************

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="smallText" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_PASSWORD_FORGOTTEN, '', 'SSL') . '">' . TEXT_PASSWORD_FORGOTTEN . '</a>'; ?></td>

</tr>

 

I think the link that is missing should call a pop-up window that loads the page info_autologon.php. The languages for info_autologon.php are inside each language folder and were not left out of v.092.

 

Any ideas on why the cookie isn't being written? And, is there some code missing for the hyperlink?


Happiness does not come from doing easy work but from the afterglow of satisfaction that comes after the achievement of a difficult task that demanded our best. --Anonymous

Share this post


Link to post
Share on other sites
I think the link that is missing should call a pop-up window that loads the page info_autologon.php. The languages for info_autologon.php are inside each language folder and were not left out of v.092.

 

I think I have fixed this problem:

 

On catalog/login.php modify this code between your <head></head> tags:

 

<script language="javascript"><!--

function session_win() { window.open("<?php echo FILENAME_INFO_SHOPPING_CART; ?>","info_shopping_cart","height=460,width=450,toolbar=no,statusbar=no,scrollbars=yes").focus();

}

 

function popupWindow(url) {window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resiza

ble=yes,copyhistory=no,width=450,height=300,screenX=150,screenY=150,top=150,left=

150')

}//--></script>

 

then modify this code on catalog/login.php:

 

<?php

// HMCS: Begin Autologon **********************************************************

if(ALLOW_AUTOLOGON != '0') {

?>

<tr>

<td> </td>

<td align="left" class="smalltext"><?php echo tep_draw_checkbox_field('remember_me','on', (($password == '') ? false : true)) . ENTRY_REMEMBER_ME . '<br>  <a href="java script:popupWindow('' . tep_href_link(FILENAME_POPUP_REMEMBER_ME_HELP) . '')">' . TEXT_REMEMBER_ME_HELP_LINK . '</a>'; ?></td>

</tr>

<?php }

// HMCS: Begin Autologon **********************************************************

?>

 

On catalog/includes/application_top.php, add this line:

 

define('FILENAME_POPUP_REMEMBER_ME_HELP', 'info_autologon.php');

 

On catalog/includes/languages/english/login.php, add this line: (You will need to add this line to login.php for each of your languages.)

 

define('TEXT_REMEMBER_ME_HELP_LINK', '<u>Save Password Help</u> [?]');

 

 

 

I hope this helps someone. :D


Happiness does not come from doing easy work but from the afterglow of satisfaction that comes after the achievement of a difficult task that demanded our best. --Anonymous

Share this post


Link to post
Share on other sites

Take it easy, take it easy...

 

The changes you are making are *not* the right way to go.

I uploaded a new version of the contrib to fix the missing define(s).

 

Go to the contribs page and download AutoLogon 0.93 BETA. You can find the changes in readme.txt.

 

We will be succesfull in implementing this thing, but it's important to coorporate otherwise I will lose track.

 

M@rcel


Greetings from Marcel

|Current version|Documentation|Contributions|

Share this post


Link to post
Share on other sites

LOL...sorry about that. I didn't mean to step on anyone's toes. I just got excited because what I did worked. :)

 

I am anxious to get this working because it is for one of my clients and the entire project needs to be finished ASAP.

 

Thanks for the contribution. I did find it well written and fairly simple to install.


Happiness does not come from doing easy work but from the afterglow of satisfaction that comes after the achievement of a difficult task that demanded our best. --Anonymous

Share this post


Link to post
Share on other sites
LOL...sorry about that. I didn't mean to step on anyone's toes. I just got excited because what I did worked. :)

 

Well, I've got long toes, but not that long. :D I was just a bit worried about the implementation getting a life of it's own.

 

Beware of the following:

Setting the autologon-parameter in Admin to:

0 = autologon disabled

1 = The user will be logged in as soon at the first visit to the site.

2 = Re-logging in will be deferred until a SSL-link is established. Normally this means when the user goes to checkout or the my-account-page. I think it should be possible to change the default.php page into a SSL-page. I have not yet tested this.

 

I have a (not released yet) version of the contrib that stores an md5-encrypted copy of the password in the cookie instead of plain-text. This should make the use of admin-value '1' a bit less insecure.

 

hth

 

M@rcel


Greetings from Marcel

|Current version|Documentation|Contributions|

Share this post


Link to post
Share on other sites

OK..so does that mean a cookie only gets written to a person's computer once they either create an account or checkout?

 

I don't think I have tried to create a new account or use the checkout since I've installed this. I have the option set in admin to #1, which is for SSL links only.


Happiness does not come from doing easy work but from the afterglow of satisfaction that comes after the achievement of a difficult task that demanded our best. --Anonymous

Share this post


Link to post
Share on other sites

I'm not sure if you got it right, let me try again 8)

=================

 

Assuming Admin/autologon is set to '1':

The cookie get's written when (in the loginproces) the remember-me box is checked AND the link is SSL.

 

The stored password is used to login automatically as soon as a SSL-link is established again. Normally this happens when the customer (who checked the remember-me box earlier) proceeds to the checkout. It also occurs when this customer goes to his "my-account"-page.

 

=================

 

Assuming Admin/autologon is set to '2':

The cookie is written when (in the loginproces) the remember-me box is checked.

 

The stored password is used to login as soon as the customer (who checked the remember-me box earlier) revisits the site.

 

=================

 

M@rcel


Greetings from Marcel

|Current version|Documentation|Contributions|

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×