TypoScript Loginbox (using kb_md5feuser and newloginbox)

Submitting your vote...
Rating: 3.8 of 5. 11 vote(s).
Click the rating bar to rate this item.

This snippet shows how to create a loginbox using TypoScript. This Loginbox works with md5 passwords (ext: md5feuser) and the new loginbox extension.

 

 

#check if there is a logged in user (a feuser has to belog atleast to one usergroup) p
[usergroup=*]

#Logoff form with username
lib.login = COA_INT
lib.login {
  10 = TEXT
  10.wrap = <span id="logoutUName">|</span>
   
  20 = TEXT
  20.typolink.parameter = {$plugin.tx_newloginbox.loginUID}
  20.typolink.returnLast = url
  20.wrap = <form action="|" method="post">
   
  30 = COA
  30 {
    5 = TEXT
    5.wrap = <input type="submit" id="logout" value="|" />
     
    10 = TEXT
    10.value = <input type="hidden" name="logintype" value="logout" />
    20 = TEXT
    20.value = <input type="hidden" name="redirect_url" value="" />
    30 = TEXT
    30.value = </form>
  }
}

# if no user is logged in we show the loginform
[else]

# Important we can only get the challenge value from kb_md5feuser only through a php script 
includeLibs.md5fepw = fileadmin/scripts/md5fepw.php
lib.login = COA_INT
lib.login {
  10 = TEXT
  10.typolink.parameter = {$plugin.tx_newloginbox.loginUID}
  10.typolink.returnLast = url
  10.wrap = <form action="|" method="post" onsubmit="superchallenge_pass(this); return true;">
   
  # form
  20 = COA
  20 {
    10 = TEXT
    10.value = Login
    10.wrap = <input type="text" name="user" onclick="this.value=''" value="|" /> <br />
    20 = TEXT
    20.wrap = <input type="password" name="pass" onclick="this.value=''" value="|" />
     
    30 = COA
    30 {
      10 = TEXT
      10.value = <input type="hidden" name="logintype" value="login" />
      20 = TEXT
      20.value = {$plugin.tx_newloginbox.storageUID}
      20.wrap = <input type="hidden" name="pid" value="|" />
       
      # Call the PHP - Script
      25 = USER
      25.userFunc = user_md5fepw->md5Challenge
       
      30 = TEXT
      30.value = <button type="submit"><img src="fileadmin/templates/res/pictures/go.gif" alt="login" /></button>
      40 = TEXT
      40.value = </form>
    }
  }
}
[usergroup]

#Select the content for the loginbox in the correct language  (in this expamle english and german)
[usergroup=*] AND [globalVar = GP:L = {$langUID_EN}]
lib.login.10.value = Hello <!--###USERNAME###-->
lib.login.30.5.value = press to logout
[else]
lib.login.10.value = Hallo <!--###USERNAME###-->
lib.login.30.5.value = zum abmelden best&auml;tigen
[global]

# show the login only on a certain page and subpages
[PIDinRootline={$siteIntern}]
lib.login.if.isTrue = 1

# enable login if the constant activateLogin = 1
[else]
lib.login.if.isTrue = {$activateLogin}
[global]

 

Here the php script. The function is copied from kb_md5feuser and slightly modified

 


<?php
class user_md5fepw {
function 
md5Challenge($content$conf)
{
$js '
function superchallenge_pass(form) {
var pass = form.pass.value;
if (pass) {
form.pass.value = MD5(form.user.value + ":" + MD5(pass) + ":" + form.challenge.value);
return true;
} else
return false;
}'
;

$GLOBALS['TSFE']->JSCode .= $js;
$GLOBALS['TSFE']->additionalHeaderData['tx_kbmd5fepw_newloginbox'] = '<script language="JavaScript" type="text/javascript" src="typo3/md5.js"></script>';
$chal_val md5(time().getmypid());
$res $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_kbmd5fepw_challenge', array('challenge' => $chal_val'tstamp' => time()));
return 
'<input type="hidden" name="challenge" value="'.$chal_val.'">';
}
}
?> 

 

 

This snippet was submitted by Stefan Galinski



Comments


Emile, 14-01-07 21:21:
Please can you explain where to put the php snippet? Thank you!
Stefan, 16-01-07 16:32:
Hi Emile, just put the php content into "fileadmin/scripts/md5fepw.php". Furthermore the constants {$plugin.tx_newloginbox.loginUID} and {$plugin.tx_newloginbox.storageUID} needs to be set. That should be done in the constants section of your template (syntax: plugin.tx_newloginbox.storageUID = <uid>). Have fun!
Jakob, 28-06-07 15:15:
Hey, and thanx for the snippet!

i have a problem, there is a warning message apparing now:

Warning: Cannot modify header information - headers already sent by (output started at
/home/.../fileadmin/scripts/md5fepw.php:22) in
/..../typo3/sysext/cms/tslib/class.tslib_fe.php on line 2898

it dissaperes when i log in as a regular fe-user?
Thomas, 07-04-08 20:28:
I encountered the same problem after moving my TYPO3 installation from windows to linux It was working fine on windows in php Version 5.2.1 and threw the above mentioned error message on Ubuntu Server (Gutsy) PHP Version 5.2.3.

On the contrary I had a rogue whitespace, space character, newline, before my <!Doctype html declaration for IE or the <?xml version="1.0" in Firefox (whichever comes first) on my windows/ PHP 5.2.1 installation which broke the standart compliance mode.

I was able to resolved both problems by removing all whitespaces and newlines after the closing ?> tag in the md5fepw.php script.

I hope this helps someone else since for a day I wished I could swap for searching the needle in a haystack rather than trying to find a rogue whitespace in TYPO3 :-)
Henning, 04-08-09 12:09:
Thanks a lot - it helped me!! ;D

Add comment

* - required field

*



*
*

Top 10 Updates

Nice fonts using Google font API geändert am  20-May-2010 16:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 18:27:15
TYPO3 SEO geändert am  30-Apr-2010 09:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 09:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 12:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 12:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 12:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 14:02:48
Sample DHTML menu geändert am  01-Feb-2009 13:51:25
A introduction to the CONTENT object geändert am  26-Jan-2009 13:20:39

Latest comments

21-Jan-2012 20:22:24
jemmkwc jemmkwc schrieb: MOGWOX , [url=http://prdpuhwzxyrc.com/]prdpuhwzxyrc[/url],...
fe_useradmin form does not save
20-Jan-2012 20:35:32
fsivjktiuld fsivjktiuld schrieb: idCmnv <a href="http://gakbrrkrxhye.com/">gakbrrkrxhye</a>
fe_useradmin form does not save
19-Jan-2012 18:05:25
bvffee bvffee schrieb: jl2vQt , [url=http://xcinvpbclrbm.com/]xcinvpbclrbm[/url],...
External links and shortcuts directly in the menu
Deutsch
Search: