Subsilver2 modify Login in header

For support and discussion related to templates, themes, and imagesets in phpBB 3.0.
Get Involved
Locked
conware
Registered User
Posts: 63
Joined: Mon Feb 28, 2011 11:23 am

Subsilver2 modify Login in header

Post by conware » Sun Jul 03, 2011 7:31 pm

Hi guys I need some help.

I modified my template file: overall_header.html.
And added a login box into my header so board users can login on each forum page.
My problem however is that the template variable {S_FORM_TOKEN} is not working on the pages.
I took a look at the index_body.html

Part of the file where is writen:

Code: Select all

<!-- IF not S_USER_LOGGED_IN and not S_IS_BOT -->
	<br clear="all" />

	<form method="post" action="{S_LOGIN_ACTION}">

	<table class="tablebg" width="100%" cellspacing="1">
	<tr>
		<td class="cat"><h4><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a></h4></td>
	</tr>
	<tr>
		<td class="row1" align="center"><span class="genmed">{L_USERNAME}:</span> <input class="post" type="text" name="username" size="10" />&nbsp; <span class="genmed">{L_PASSWORD}:</span> <input class="post" type="password" name="password" size="10" />&nbsp; <!-- IF S_AUTOLOGIN_ENABLED --> <span class="gensmall">{L_LOG_ME_IN}</span> <input type="checkbox" class="radio" name="autologin" /><!-- ENDIF -->&nbsp; <input type="submit" class="btnmain" name="login" value="{L_LOGIN}" /></td>
	</tr>
	</table>
	{S_LOGIN_REDIRECT}
	{S_FORM_TOKEN}
	</form>
<!-- ENDIF -->
However on this page the S_FORM_TOKEN is not doing anything and this is a mistake made in the forum software because S_FORM_TOKEN should be used with add_form_key('name_of_form'); (found in the wiki Docs). Sins theres not name to the form example <form action="login" name="name_of_form"> It won't work.
So where should I call add_form_key to use it on all my phpbb pages sins Im using the login box in the header of forums?

Thanks for any help. :D

statm
Registered User
Posts: 447
Joined: Thu Jul 21, 2005 11:03 am
Location: NC, USA
Name: Matt
Contact:

Re: Subsilver2 modify Login in header

Post by statm » Sun Jul 03, 2011 10:10 pm

You do not need to use S_FORM_TOKEN in a header login box. I have a login box that I use for every page on one of my styles and it does not include S_FORM_TOKEN in the form. It is from a prosilver based style so you will have to adapt it into your table if you want to use it.

Heres a sample of my header that includes the login html, in overall_header.html...

Code: Select all

<!-- IF not S_USER_LOGGED_IN -->
        			<div class="navlinks">
						<ul class="linklist">
							<li class="icon-home" style="padding-top:1px">
								<a href="{U_INDEX}" accesskey="h">{L_INDEX}</a>
								<!-- BEGIN navlinks -->
									<strong>&#8249;</strong> <a href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a>
								<!-- END navlinks -->
							</li>
							<!-- IF not S_DISPLAY_FULL_LOGIN and not S_IS_BOT -->
								<li class="rightside">
									<form method="post" action="{S_LOGIN_ACTION}" style="text-align:right">
				    				<fieldset>
										<input type="text" name="username" class="quick-login-form" title="{L_USERNAME}" value="{L_USERNAME}" onfocus="if (this.value == '{L_USERNAME}') {this.value = '';}" onblur="if (this.value == '') {this.value = '{L_USERNAME}';}" />
                        				<input type="password" name="password" class="quick-login-form" title="{L_PASSWORD}" value="********" onfocus="if (this.value == '********') {this.value = '';}" onblur="if (this.value == '') {this.value = '********';}" />
										<input type="submit" name="login" value="{L_LOGIN}" class="quick-login-button" />                        
									</fieldset>
									{S_LOGIN_REDIRECT}
									</form>
								</li>
							<!-- ENDIF -->
						</ul>
             </div>
                <!-- ENDIF -->
Anyone can feel free to contradict this but it works for me. I hope this helps!

conware
Registered User
Posts: 63
Joined: Mon Feb 28, 2011 11:23 am

Re: Subsilver2 modify Login in header

Post by conware » Mon Jul 04, 2011 8:43 am

Thanks statm, I wasn't sure if I could use the form without the S_FORM_TOKEN.
However I still think its better to use it and I found the solution:

This is my login from my subsilver template:

Code: Select all

<!-- IF not S_USER_LOGGED_IN --><div id="not_logged_in">		
			<form name="login" action="{S_LOGIN_ACTION}" method="post">
			<fieldset>
				<label for="username">
					<input type="text" id="username" class="field rounded" name="username" maxlength="14" tabindex="2" 
					onclick="if (this.value=='username') this.value='';" onblur="if (this.value=='') this.value = 'username';" value="username" />
				</label>
				<label for="remember">
					<input type="checkbox" class="radio" name="autologin" id="remember" tabindex="4" /> Remember me?
				</label>
				<label for="password">
					<input type="password" id="password" class="field rounded" name="password" maxlength="20" tabindex="3"
					onclick="if (this.value=='password') this.value='';" onblur="if (this.value=='') this.value = 'password';" value="password" />
				</label>
				<label for="hide_online">
					<input type="checkbox" class="radio" name="viewonline" id="hide_online" tabindex="5" /> Hide online?
				</label>
				{S_FORM_TOKEN}
				{S_LOGIN_REDIRECT}
				<input type="submit" class="button" value="Login" name="login" tabindex="6" />
			</fieldset>
			</form>
		</div><!-- ENDIF -->
Next I opened up includes/functions.php and added after:

Code: Select all

    // Send a proper content-language to the output
    $user_lang = $user->lang['USER_LANG'];
    if (strpos($user_lang, '-x-') !== false)
    {
        $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
    } 
add_form_key('login');

It seems to work now. But im not sure it I did this correct does anyone know if this won't effect anything else?

Locked

Return to “[3.0.x] Styles Support & Discussion”