This topic is locked

PHPRunner and Typo3

5/21/2010 5:45:44 PM
PHPRunner Tips and Tricks
admin

This tutorial was tested with Typo3 4.3.3 and PHPRunner 5.2. Should work the same way with other versions of Typo3 and PHPRunner.
A special thank you to Georg Lohr who helped me to get through Typo3 setup labyrinth.
If you already have a working Typo3 website with login form proceed to bullet 4.
1. Create 'Storage folder' page
This is special page of System folder type. On 'Options' tab select 'Website users' from 'Contains plugins' dropdown box.
2. Enable felogin extension in Typo3 and insert login into one of pages.
Add a login form to one of pages via New content->Login form. Choose 'Storage folder' page as storage folder.
3. Add website usergroup and users
Right click on 'Storage folder' page and choose New->Website usergroup. Create a new usergroup. Right click on this usergroup and choose New->Website user. Add a few users.
4. Install plugin (ffiframe) Flexform based IFrame
5. Modify Flexform based IFrame plugin
Add line in bold to typo3conf\ext\ffiframe\pi1\class.tx_ffiframe_pi1.php file.

foreach( $getVars as $var ) {

if ( t3lib_div::_GET( $var ) ) {

$params[$var] = t3lib_div::removeXSS( t3lib_div::_GET( $var ) );

}

}
$params["sessionid"]=$GLOBALS['TSFE']->fe_user->user['ses_id'];
if ( strstr( $this->config['src'], '?' ) ) {

$additionalParams = t3lib_div::implodeArrayForUrl( '',$params );


The idea is to pass Typo3 session id to PHPRunner application via iframe URL. If someone knows a better way to do this without modifying a plugin I'll gladly update this tutorial.
6. Create a new page in Typo3.
Insert Flexform based IFrame plugin. In plugin properties enter PHPRunner application URL i.e. http://localhost:81/tmp/menu.php
7. Add code to 'After application initialized' event in PHPRunner:



$tpconn=db_connect();
// Get sessionvariable of Joomla-Session over the URL which passes the Joomla-Wrapper to the iframe

if (@$_GET["sessionid"])

$_SESSION["sessionid"] = @$_GET["sessionid"];
if (@$_SESSION["sessionid"])

{
//Get the values out of the fe_sessions table:
$rs=db_query("select u.username, g.title from `fe_sessions` s

inner join `fe_users` u on u.uid=s.ses_userid

inner join `fe_groups` g on u.usergroup=g.uid

where s.ses_id='" . $_SESSION["sessionid"]. "'",$tpconn);

$data=db_fetch_array($rs);

if($data)

// log in

{

$_SESSION["UserID"] = $data["username"];

$_SESSION["GroupID"] = $data["title"];

$_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;

}

else

// log out

{

$_SESSION["UserID"] = "";

$_SESSION["AccessLevel"] = "";

$_SESSION["GroupID"] = "";

}
}


This code snippet assumes PHPRunner application shares database with Typo3. This is not a requirement though. If you want to keep databases separate - connect to Typo3 database manually in the very beginning of 'After application initialized' event.
8. More security options
If your PHPRunner applications uses advanced security options or AfterSuccessfulLogin event you need to copy some code from login.php to 'After application initialized' event.
Open login.php file in any text editor and find the following section:

if($logged)

{

$_SESSION["UserID"] = $pUsername;

$_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;
...
if($myurl)

header("Location: ".$myurl);

else

header("Location: ".$defaulturl);

return;
}


Select and copy everything between $_SESSION["AccessLevel"] = ACCESS_LEVEL_USER; and if($myurl)

Paste it to the end of 'After application initialized' event;
This is it.

A
asawyer13DevClub member 12/26/2011

Does anyone have a public site that uses Typo3 and PHPR? One that I can see how they look together in a real environment?

Alan