1. Enable PHP filter
'Configuration and modules' menu, 'Modules' tab. Enable 'PHP filter'.
2. Create a new article in Drupal
Use 'PHP code' as text format. Paste the following code to the body:
Quote
<?php
global $user;
echo '<p><iframe scrolling="auto" src="http://localhost/dru...n_cars_list.php?sessionid='. @$user->sid .'" style="border-style: hidden; width: 100%; height: 500px;"></iframe></p>';
?>
global $user;
echo '<p><iframe scrolling="auto" src="http://localhost/dru...n_cars_list.php?sessionid='. @$user->sid .'" style="border-style: hidden; width: 100%; height: 500px;"></iframe></p>';
?>
Replace text in bold with your application URL.
3. In PHPRunner application add the following code to 'After application initialized' event:
$dconn=db_connect();
if (@$_GET["sessionid"])
$_SESSION["sessionid"] = @$_GET["sessionid"];
if (@$_SESSION["sessionid"])
{
//Get the get username/role from the database
$sql="select u.*,s.*,ur.rid, r.name as rolename
from sessions s
inner join users u on s.uid=u.uid
left outer join users_roles ur on u.uid=ur.uid
LEFT OUTER JOIN role r ON r.rid = ur.rid
where u.status=1 and u.uid>0 and s.sid='" . $_SESSION["sessionid"]. "'";
$rs=db_query($sql,$dconn);
$data=db_fetch_array($rs);
if($data)
{
$_SESSION["UserID"] = $data["name"];
if (!is_null($data["rolename"]))
{
$_SESSION["GroupID"] = $data["rolename"];
if ($data["rolename"]=='administrator')
$_SESSION["AccessLevel"] = ACCESS_LEVEL_ADMINGROUP;
else
$_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;
}
else
$_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;
}
else
// log out
{
session_unset();}
}
This code snippet assumes PHPRunner application shares database with Drupal. This is not a requirement though. If you want to keep databases separate - connect to Drupal database manually in the very beginning of 'After application initialized' event.
4. 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.
Post a Comment