Accessing php variables from outside phpBB instances

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Josh18657
Registered User
Posts: 425
Joined: Wed Nov 30, 2005 9:55 pm
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Josh18657 » Sun Aug 26, 2007 10:15 am

armsch9 wrote:Ok we're getting somewhere now, I put this in and got this error:
Hacking attempt
Fatal error: Call to undefined function: session_pagestart() in /home/www/bottleweb.org/wiki/index.php on line 7
line 7 of index.php is:

Code: Select all

$userdata = session_pagestart($user_ip, PAGE_INDEX);
Can I bypass this hacking protection thing? or is that a bad idea?
make sure you still have the

Code: Select all

define('IN_PHPBB', true);
part of the code in there
I can help you edit your forums at a reasonable price, send a PM if you can't get something figured out here.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 50701
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf » Sun Aug 26, 2007 12:17 pm

You didnt include all of the phpBB code.
You need to include common.php before you can call any of those functions, and you have to have the

Code: Select all

define('IN_PHPBB', true);
to fix the hacking error

User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 » Sun Aug 26, 2007 1:54 pm

I had the complete thing in there:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
underneath the <?php, and I tried it for both the bottleweb.php and index.php files.
Image

User avatar
Brf
Support Team Member
Support Team Member
Posts: 50701
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf » Sun Aug 26, 2007 6:07 pm

armsch9 wrote:$phpbb_root_path = './';

You have your index.php in the same folder as phpbb's index.php? How is that?

User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 » Mon Aug 27, 2007 7:09 am

no, index.php for the wiki is in /wiki whereas the forum is in the main directory. I've tried manually setting $phpbb_root_path = 'http://bottleweb.org'; and that didn't work either. Any ideas?
Image

Josh18657
Registered User
Posts: 425
Joined: Wed Nov 30, 2005 9:55 pm
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Josh18657 » Mon Aug 27, 2007 7:32 am

armsch9 wrote:no, index.php for the wiki is in /wiki whereas the forum is in the main directory. I've tried manually setting $phpbb_root_path = 'http://bottleweb.org'; and that didn't work either. Any ideas?
root path should be ././ or ../ or something like that
I can help you edit your forums at a reasonable price, send a PM if you can't get something figured out here.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 50701
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf » Mon Aug 27, 2007 12:00 pm

armsch9 wrote:no, index.php for the wiki is in /wiki whereas the forum is in the main directory. I've tried manually setting $phpbb_root_path = 'http://bottleweb.org'; and that didn't work either. Any ideas?
The root path is a relative path, so you should be using:

Code: Select all

$phpbb_root_path = '../';

User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 » Wed Sep 05, 2007 10:36 am

This still doesn't work, it just comes up as a blank image when I link to {IMAGE_PRIVMSG} (an image link I made that contains links to a jpg depending on the message status).

I've added the code:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = '../';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
to my /wiki/index.php file. Do I need to bring all the files into the /wiki folder? This is getting frustrating as it's something which I thought would have been quite simple. I've tried mediawiki forums but they just tell me "it's easy" and don't really help me.
Image

User avatar
Brf
Support Team Member
Support Team Member
Posts: 50701
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf » Wed Sep 05, 2007 11:30 am

armsch9 wrote:Do I need to bring all the files into the /wiki folder?
No. That "$phpbb_root_path = '../';" is telling the includes to look up one level for the phpbb files it is including.
armsch9 wrote: it just comes up as a blank image when I link to {IMAGE_PRIVMSG}
I see nothing in your posted code about {IMAGE_PRIVMSG}. Are you saying that the page reders OK, but the image doesnt show? Did you try a "view source" on your HTML to see what the image link is to?

User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 » Sun Sep 09, 2007 7:25 am

it's a variable I created in page_header.php, it doesn't pick it up at all as if it didn't load the include files. if I check the url that the image points to it looks something like "http://bottleweb.org/wiki/{IMAGE_PRIVMSG}", i.e. it didn't load the variable. Am I missing something? (sorry about the late reply I thought I answered already but it didn't come up).
Image

User avatar
Brf
Support Team Member
Support Team Member
Posts: 50701
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf » Sun Sep 09, 2007 1:09 pm

armsch9 wrote: it's a variable I created in page_header.php
Where exactly did you include the {IMAGE_PRIVMSG} tag? In which template file?

How are you defining 'IMAGE_PRIVMSG' in page_header.php?

User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 » Sun Sep 09, 2007 2:34 pm

Sorry I should have told you this before.

In page_header.php I have modified the "check for messages" part of the code to this:

Code: Select all

//
// Obtain number of new private messages
// if user is logged in
//

	$privmsg_normal = '/templates/Appalachia/images/custom_buttons/PM_normal.jpg';
	$privmsg_normal_hover = '/templates/Appalachia/images/custom_buttons/PM_normal_hover.jpg';
	$privmsg_new = '/templates/Appalachia/images/custom_buttons/PM_new.jpg';
	$privmsg_new_hover = '/templates/Appalachia/images/custom_buttons/PM_new_hover.jpg';

if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) )
{
	if ( $userdata['user_new_privmsg'] )
	{
		$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
		$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);

		if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
		{
			$sql = "UPDATE " . USERS_TABLE . "
				SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
				WHERE user_id = " . $userdata['user_id'];
			if ( !$db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, 'Could not update private message new/read time for user', '', __LINE__, __FILE__, $sql);
			}

			$s_privmsg_new = 1;
			$icon_pm = $images['pm_new_msg'];
			$image_privmsg = $privmsg_new;
			$image_privmsg_hover = $privmsg_new_hover;
		}
		else
		{
			$s_privmsg_new = 0;
			$icon_pm = $images['pm_new_msg'];
			$image_privmsg = $privmsg_normal;
			$image_privmsg_hover = $privmsg_normal_hover;
		}
	}
	else
	{
		$l_privmsgs_text = $lang['No_new_pm'];
		$s_privmsg_new = 0;
		$icon_pm = $images['pm_no_new_msg'];
		$image_privmsg = $privmsg_normal;
		$image_privmsg_hover = $privmsg_normal_hover;
	}

	if ( $userdata['user_unread_privmsg'] )
	{
		$l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
		$l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
	}
	else
	{
		$l_privmsgs_text_unread = $lang['No_unread_pm'];
	}
}
else
{
	$icon_pm = $images['pm_no_new_msg'];
	$l_privmsgs_text = $lang['Login_check_pm'];
	$l_privmsgs_text_unread = '';
	$s_privmsg_new = 0;
	$image_privmsg = $privmsg_normal;
	$image_privmsg_hover = $privmsg_normal_hover;
}
so basically I create $image_privmsg, and it will contain a blank picture if there is no mail and an image of an envelope when there is mail. You can see this as the "PM" button at http://bottleweb.org/forum.php. I also have a hover button, which is bascially the same thing just pushed in.

Then near the end of the code I added:

Code: Select all

	'IMAGE_PRIVMSG' => $image_privmsg,
	'IMAGE_PRIVMSG_HOVER' => $image_privmsg_hover,
I call these from the overall_header.tpl file to get the images for the PM button. I've also done this to get log in/ log out buttons for the forum. It works fine from within phpBB.
Image

User avatar
Brf
Support Team Member
Support Team Member
Posts: 50701
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf » Sun Sep 09, 2007 2:44 pm

It looks fine to me in phpBB. Where are you seeing it not working?

User avatar
armsch9
Registered User
Posts: 82
Joined: Wed Jul 11, 2007 4:12 pm

Re: Accessing php variables from outside phpBB instances

Post by armsch9 » Mon Sep 10, 2007 4:27 am

give me a few hours I'll put it up and show you
Image

User avatar
Brf
Support Team Member
Support Team Member
Posts: 50701
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Accessing php variables from outside phpBB instances

Post by Brf » Mon Sep 10, 2007 12:10 pm

You cant just describe it to me?
Are you putting {IMAGE_PRIVMSG} in a template file, which is invoked by the $template object after including page_header.php?

Post Reply

Return to “[2.0.x] MOD Writers Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests