PDA

View Full Version : Using vB data in another script...


Martin CX
07-24-2002, 04:58 AM
We're running two BB systems on our site; a vB and a proprietary board with threading. If vB3 ever arrives we'll close the proprietary board down but until then I'm looking at ways of making the change more gradual for our users.

What I am working on is using the vB member info in the proprietary board (prop board) so that users have to login before using the prop board.

Granted, I'm a newbie when it comes to PHP scripting, but this is a bit more frustrating than I thought it would be.

I know I have to require the global.php, but as this is in another subdirectory than the rest of the props board (as in root/forum1 where the other is in root/forum2), I'm not sure how to go about doing it in the best if I use chdir ("../forum2/"); do I need to chdir("../forum1/") back before continuing with the script?

When I c'n'p'ed a small script from another thread (forgot which) just to test it:if_($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
echo "Welcome_back, <b>$username</b>";I got parse errors, but are they related to a failed require of global.php or have I missed a typo? :(

Ir's rather early - local time - and I haven't really slept, so I'm probably just missing something very basic, but it would really make my day, if one of you could push me in the right direction here.

Thanks,

Martin

P.S: I know of the (two) hacks, but I'm not interested in those, but I'm not really looking for any large-scale solutions. I just need to get these kinks ironed out.

Admin
07-24-2002, 07:02 AM
<?php
error_reporting(7);
chdir('/home/user/htdocs/forums');
require('./global.php');

if ($bbuserinfo['userid'] != 0) {
$username = $bbuserinfo['username'];
echo "Welcome back, <b>$username</b>.";
}

?>
Change the path in the chdir() function to the real one.

Martin CX
07-24-2002, 09:56 AM
It still won't do as I want it to, though. :( The same parse errors. I'm almost certain I've got the path right (this time).

Admin
07-24-2002, 10:05 AM
There are no errors with that script. Make sure you are uploading in ASCII mode and using a normal text editor (i.e not Word).

Martin CX
07-24-2002, 10:51 AM
This is the message I'm given:

Parse error: parse error in /home/yada/yada-yada/yada/head.php on line 71

Line 71 is the line with the if-statement:<?php
error reporting(7);
chdir('/home/yada/yada-yada/forums');
require('./global.php');
if ($bbuserinfo['userid'] != 0) {
$username = $bbuserinfo['username'];
echo "Welcome_back, <b>$username</b>.";
} else {
echo "Please log in.";
}
?>

Admin
07-24-2002, 11:04 AM
Your error is before my code, then. What is the full file?

Logician
07-24-2002, 11:04 AM
Are you an Opera or Mac user?

Take a look at your "if" line in your first message: There is an alien char right after if in your code. Opera browser converts spaces to some alien chars when you copy paste it from your browser screen. So try these:

a) Delete all space chars from your code and rewrite them by pressing SPACE button.

b) Do not copy/paste, write the section by hand.

c) Get IE or netscape! :)

Martin CX
07-24-2002, 11:07 AM
I AM using Opera. (And quite a happy one - usually ;)) Thank you for your suggestion, I'll try. (fingers crossed) :)

wooolF[RM]
07-25-2002, 09:13 AM
]Originally posted by FireFly
<?php
error_reporting(7);
chdir('/home/user/htdocs/forums');
require('./global.php');

if ($bbuserinfo['userid'] != 0) {
$username = $bbuserinfo['username'];
echo "Welcome back, <b>$username</b>.";
}

?>
Change the path in the chdir() function to the real one.

I have tried to use this code as block on a phpNuke...
Result:Parse error: parse error, unexpected T_STRING in /home/wooolf/WWW/phpnuke/themes/OceanBlue/theme.php(358) : eval()'d code on line 2
where line 358 is : eval($content);} in this code:// Now We Can Incluse Any PHP Scripts
if (substr($content,0,2) != "<?")
echo $content;
else { $content = str_replace ("<?", "", $content);
eval($content);}
echo "</td>\n"
//End Of Hack

wooolF[RM]
07-25-2002, 09:19 AM
]I have also tried to use this script:<?php include('http://www.blabla.com/forum/welcome.php');?>which gave the same error... :(

IS it possible to use vB data on pages outside of the /forum folder? I'm mostly interested in including php files as I amde 3-4 of them and thought it willl work, but I jest get errors... :(