TypoScript Loginbox (using kb_md5feuser and newloginbox)

Submitting your vote...
Rating: 3.5 of 5. 6 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 20:21:
Please can you explain where to put the php snippet? Thank you!
Stefan, 16-01-07 15: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 13: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 18: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 :-)

Add comment

* - required field

*



*
*

Top 10 Updates

Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 10:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 10:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 13:02:48
Sample DHTML menu geändert am  01-Feb-2009 12:51:25
A introduction to the CONTENT object geändert am  26-Jan-2009 12:20:39
Sample for dynamic image masks geändert am  16-Dec-2008 15:42:32
Useful Links geändert am  11-Dec-2008 10:06:17
Using Transparent PNG's in IE5/6 without JavaScript geändert am  04-Oct-2008 12:27:15
Using lightbox without extension geändert am  13-Jun-2008 14:20:51
Custom field for GMENU alt text geändert am  13-Jun-2008 13:58:07

Latest comments

06-Jul-2009 23:01:25
Charley schrieb: Same thing slightly changed for tableless design. There is a div class="clearer" to clear any...
TS-based Searchbox for Indexed Search
02-Jul-2009 10:58:10
Sergii schrieb: not working
tt_news frontend editing
30-Jun-2009 12:25:44
JG schrieb: Doesn't work for me also.
Show "Not in Menu" in a Sitemap
Deutsch
Search: