Forums: PHPRunner and Drupal - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PHPRunner and Drupal how to integrate PHPRunner application into Drupal website

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 8453
  • Joined: 03-February 03

Posted 02 January 2010 - 11:44 PM

This tutorial applies to Drupal 7.x and PHPRunner 5.1 or better. Should work the same way with earlier versions of Drupal.

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>';

?>


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.
Best regards,
Sergey Kornilov
0

#2 User is offline   Form 

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 04-February 10

Posted 24 April 2010 - 07:18 AM

View Postadmin, on 02 January 2010 - 11:44 PM, said:

This tutorial applies to Drupal 7.x and PHPRunner 5.1 or better. Should work the same way with earlier versions of Drupal.

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>';

?>


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.




URGENT !!!!!!
Hallo
I do not understand I'm Italian
please explain better by adding photos of the procedure
or
please explain better by adding video of the procedure
I'm sure his support will solve the problem
many thanks
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users