Page 2 of 3

Re: Accessing php variables from outside phpBB instances

Posted: Sun Aug 26, 2007 10:15 am
by Josh18657
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

Re: Accessing php variables from outside phpBB instances

Posted: Sun Aug 26, 2007 12:17 pm
by Brf
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

Re: Accessing php variables from outside phpBB instances

Posted: Sun Aug 26, 2007 1:54 pm
by armsch9
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.

Re: Accessing php variables from outside phpBB instances

Posted: Sun Aug 26, 2007 6:07 pm
by Brf
armsch9 wrote:$phpbb_root_path = './';

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

Re: Accessing php variables from outside phpBB instances

Posted: Mon Aug 27, 2007 7:09 am
by armsch9
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?

Re: Accessing php variables from outside phpBB instances

Posted: Mon Aug 27, 2007 7:32 am
by Josh18657
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

Re: Accessing php variables from outside phpBB instances

Posted: Mon Aug 27, 2007 12:00 pm
by Brf
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 = '../';

Re: Accessing php variables from outside phpBB instances

Posted: Wed Sep 05, 2007 10:36 am
by armsch9
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.

Re: Accessing php variables from outside phpBB instances

Posted: Wed Sep 05, 2007 11:30 am
by Brf
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?

Re: Accessing php variables from outside phpBB instances

Posted: Sun Sep 09, 2007 7:25 am
by armsch9
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).

Re: Accessing php variables from outside phpBB instances

Posted: Sun Sep 09, 2007 1:09 pm
by Brf
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?

Re: Accessing php variables from outside phpBB instances

Posted: Sun Sep 09, 2007 2:34 pm
by armsch9
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.

Re: Accessing php variables from outside phpBB instances

Posted: Sun Sep 09, 2007 2:44 pm
by Brf
It looks fine to me in phpBB. Where are you seeing it not working?

Re: Accessing php variables from outside phpBB instances

Posted: Mon Sep 10, 2007 4:27 am
by armsch9
give me a few hours I'll put it up and show you

Re: Accessing php variables from outside phpBB instances

Posted: Mon Sep 10, 2007 12:10 pm
by Brf
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?