1 頁 (共 1 頁)

[教學]自動記憶帳號

發表於 : 2007-10-13 17:24
liaweg
如果覺得每次都要打帳號是件很煩的事情,大家可以參考看看

1. 修改 styles\prosilver\login_body.html

搜尋

代碼: 選擇全部

		
                <!-- IF S_DISPLAY_FULL_LOGIN -->
		<dl>
			<!-- IF S_AUTOLOGIN_ENABLED --><dd><label for="autologin"><input type="checkbox" name="autologin" id="autologin" tabindex="4" /> {L_LOG_ME_IN}</label></dd><!-- ENDIF -->
			<!--<dd><label for="viewonline"><input type="checkbox" name="viewonline" id="viewonline" tabindex="5" /> {L_HIDE_ME}</label></dd> -->
		</dl>
		<!-- ENDIF -->
改為

代碼: 選擇全部

		<!-- IF S_DISPLAY_FULL_LOGIN -->
		<dl>
			<dd><label for="autosaveaccount"><input type="checkbox" name="autosaveaccount" id="autosaveaccount" tabindex="4" {AUTO_SAVE_ACCOUNT} /> {L_AUTO_SAVE_ACCOUNT}</label></dd>	
			<!-- IF S_AUTOLOGIN_ENABLED --><dd><label for="autologin"><input type="checkbox" name="autologin" id="autologin" tabindex="4" /> {L_LOG_ME_IN}</label></dd><!-- ENDIF -->
			<!--<dd><label for="viewonline"><input type="checkbox" name="viewonline" id="viewonline" tabindex="5" /> {L_HIDE_ME}</label></dd> -->
		</dl>
		<!-- ENDIF -->
2. 修改 language\zh_cmn_hant(目前使用的語系檔)\common.php

在檔案最後面

代碼: 選擇全部

));

?>
的上方新增'AUTO_SAVE_ACCOUNT' => '記住我的帳號',

代碼: 選擇全部

'AUTO_SAVE_ACCOUNT' => '記住我的帳號',
));

?>
3. 修改 includes\auth.php

搜尋

代碼: 選擇全部

	var $acl = array();
	var $cache = array();
	var $acl_options = array();
	var $acl_forum_ids = false;
改為

代碼: 選擇全部

	var $acl = array();
	var $cache = array();
	var $acl_options = array();
	var $acl_forum_ids = false;
	var $autosaveaccount =false;
搜尋

代碼: 選擇全部

					return array(
						'status'		=> LOGIN_SUCCESS,
						'error_msg'		=> false,
						'user_row'		=> $login['user_row'],
					);
改為

代碼: 選擇全部

	$this->auto_save_account($user_email);
	return array(
		'status'		=> LOGIN_SUCCESS,
		'error_msg'		=> false,
		'user_row'		=> $login['user_row'],
	);
然後新增2個function

代碼: 選擇全部

/*
*設定是否要自動儲存帳號
*/	
	function set_auto_save_account($value)
	{
		$this->autosaveaccount = $value;
	}
	
/*
*set save user_email or not
*/
	function auto_save_account($user_email)
	{
		global $user;
		
		$cookie_expire = time() + (($config['max_autologin_time']) ? 86400 * (int) $config['max_autologin_time'] : 31536000);

		if($this->autosaveaccount)
		{
			$user->set_cookie('um', $user_email, $cookie_expire);
		}
		else
		{
			$user->set_cookie('um', '', $cookie_expire);		
		}
	}
}


4. 修改 includes\funtions.php

搜尋

代碼: 選擇全部

$autologin		 = (!empty($_POST['autologin'])) ? true : false;
改為

代碼: 選擇全部

$autosaveaccount = (!empty($_POST['autosaveaccount'])) ? true : false;
$autologin		 = (!empty($_POST['autologin'])) ? true : false;
搜层

代碼: 選擇全部

// If authentication is successful we redirect user to previous page
改為

代碼: 選擇全部

// If authentication is successful we redirect user to previous page
$auth->set_auto_save_account($autosaveaccount);
搜尋

代碼: 選擇全部

USER_NAME'=> ($admin) ? $user->data['user_name'] : '')
改為

代碼: 選擇全部

'USER_NAME'  => ($admin) ?  $user->data['user_name'] : 
								   (request_var($config['cookie_name'] . '_um', '', false, true) != '') ? 
									request_var($config['cookie_name'] . '_um', '', false, true) : '',
'AUTO_SAVE_ACCOUNT'  => (request_var($config['cookie_name'] . '_um', '', false, true) != '') ? 'checked' : '')

第一次PO文章請大家多多包含 :-D

完成畫面 http://www.i-city.com.tw/sign_up.php?mode=login