View Single Post
  #15  
Old 05-23-2003, 12:35 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default

Here's what's needed. I'm using I beleive 3.2.2, not positive on that.

Create a sub-folder in the Modules folder called: Save_Login

Create a file in the sub-folder called: set_cookie.php and put this code in it:

Code:
<? // Set cookie with login name $savelogin = $user_data['login']; setcookie("LoginCookie", $savelogin, time()+3600*24*180, "/", $xcart_http_host); $savelogintype = C; setcookie("LoginTypeCookie", $savelogintype, time()+3600*24*180, "/", $xcart_http_host); ?>

Create another file in that subfolder called: reset_cookie.php with this code in it:

Code:
<? // Set cookie with login name $savelogin = ""; setcookie("LoginCookie", $savelogin, time()+3600*24*180, "/", $xcart_http_host); $savelogintype = ""; setcookie("LoginTypeCookie", $savelogintype, time()+3600*24*180, "/", $xcart_http_host); ?>

Open include/check_useraccount.php and change to look like this:

Code:
<? # # $Id: check_useraccount.php,v 1.12.2.4 2002/12/11 12:29:10 svowl Exp $ # # This script authenticates user (session variables "login" and "login_type" # if ($HTTP_POST_VARS["login"] || $HTTP_GET_VARS["login"] || $HTTP_COOKIE_VARS["login"] || $HTTP_POST_VARS["login_type"] || $HTTP_GET_VARS["login_type"] || $HTTP_COOKIE_VARS["login_type"]) { header("Location: ../customer/error_message.php?access_denied"); exit(); } if ($login_type!=$current_area && !empty($login)) { $logged=$login; $login=""; } elseif ($login_type==$current_area && !empty($logged)) { $login=$logged; $logged=""; } $LoginCookie = $_COOKIE['LoginCookie']; $LoginTypeCookie = $_COOKIE['LoginTypeCookie']; if ($LoginCookie != "" && $LoginTypeCookie == "C") { $login = $LoginCookie; $login_type = $LoginTypeCookie; $logged = $login; } session_register("login"); session_register("login_type"); session_register("logged"); if($login) { $user_account=func_query_first("select login, membership from $sql_tbl[customers] where login='$login'"); if(empty($user_account)) { $login=""; $login_type=""; } } $smarty->assign("login",$login); $smarty->assign("usertype",$current_area); ?>

Open up /include/login.php and find where it says this:

Code:
# 1) generate $last_login by current timestamp and update database # 2) insert entry into login history # db_query("update $sql_tbl[customers] set last_login='".time()."' where login='$login'"); db_query("insert into $sql_tbl[login_history] (login, date_time, usertype, action, status, ip) values ('$username',now(),'$usertype','login','success','$REMOTE_ADDR')");

AFTER that, add this:

Code:
# # Set Remember Login # if ($login_type == "C" && $remember == "Y") { include "../modules/Save_Login/set_cookie.php"; }

Also in include/login.php find this:

Code:
if($mode=="logout") { # # Insert entry into login_history # db_query("insert into $sql_tbl[login_history] (login, date_time, usertype, action, status, ip) values ('$login',now(),'$login_type','logout','success','$REMOTE_ADDR')");

AFTER that add:

Code:
include "../modules/Save_Login/reset_cookie.php";

Open up skin1/auth.tpl (Note: I believe I've made some slight changes to this file, maybe just adding the "navlink" class). File should look similar to this:

Code:
{* $Id: auth.tpl,v 1.19 2002/09/10 12:36:33 zorg Exp $ *} {literal} <script LANGUAGE="JavaScript"> <!-- function confirmSubmit() { if (document.authform.remember.checked == true) { alert("By choosing to remain logged in all the time, others on your computer can access your account. Though we will never store credit card information, you will be held responsible for any orders placed on your account. In the future you can log out by clicking: Logoff"); document.authform.submit(); } } // --> </script> {/literal} <TABLE border=0 cellPadding=5 cellSpacing=0 width=100%> <FORM action=../include/login.php method=post name=authform> <tr><td class="TableRight" colspan=2> {if $usertype eq "C" or ($usertype eq "B" and $config.Modules.partner_register eq "Y")}<font face="verdana" size="1">Register Free|{/if}Lost Pass</font> </td></tr> <tr><td class="TableRight" colspan=2> <font class="TableRight">{$lng.lbl_username}</font> <input type=text name=username size=16 class="box"> <font class="TableRight">{$lng.lbl_password}</font> <input type=password name=password size=16 class="box"> <input type=hidden name=mode value=login> {if $active_modules.Simple_Mode ne "" and $usertype ne "C" and $usertype ne "B"} <input type=hidden name=usertype value="P"> {else} <input type=hidden name=usertype value="{$usertype}"> {/if} <input type=hidden name=redirect value="{$redirect}"> <input type="checkbox" name="remember" value="Y"> <font size="1">Remember Me</font> </td></tr> <tr> <td height=20 valign="bottom" colspan="2" class="TableRight"> <a class="navlink" onclick="confirmSubmit()">{include file="buttons/login_menu.tpl"}</a> </td> </tr> </form> </table>
Reply With Quote