vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Trick to using VB variables on Non-vb pages... (https://vborg.vbsupport.ru/showthread.php?t=47855)

stryka 01-18-2003 08:11 PM

Trick to using VB variables on Non-vb pages...
 
Ok...

Do i have to use ECHO commands in order to use the variables within GLOBAL.php?

I thought it was simple as this...
<html>
<?
require("global.php");

?>

<p> Hello... my name is $username</>

</html>

but... i assume you have to do the following:

<html>
<?
require("global.php");

echo('<p> Hello... my name is $username</>');
?>
</html>

Is there an easier way... what is the right way? I want learn to code indpependent pages of VB but use the VB variables.... if the echo command is the only way then so be it... but I do a visual/code upgrade every 6 months and the echo command may seem to be bit too much...

Everyone has asked this question... and the response is just use GLOBAL.php and sessions in the url... etc... but how... write out some sample code for the newbies.... and once we learn how we will do the same...

Thanx

NTLDR 01-18-2003 08:16 PM

Firstly only require global.php once at the top of the page, then you have all of the vB variables and functions avalible to you:

PHP Code:

<?php
require("./global.php");
?>
<html>
<body>
<p> Hello... my name is <?php echo $bbuserinfo[username]; ?></p>
</body>
</html>


Sketch 01-18-2003 10:28 PM

hmmmm, not quite. If the file that is calling global is outside of the forum tree then global.php is going to bomb out as soon as it starts hitting the require()'s. I'd like to know if there's an abstraction method to get accurate paths all the time, whether global.php is being called within the directory tree as in vBulletin or if it'bs being called from outside.

Aaron

colicab-d 01-18-2003 10:30 PM

why not put ./forum/global.php ?? soz just my thought i dont even know php lol

Davey 01-19-2003 01:11 AM

Actually that doesn't work in the slightest.
In my /public/ directory, I want my index page.
/vB/global.php is the location of global.php from my index page, and this is what I used:
PHP Code:

<?php
require("./vB/global.php");
?>
<html>
    <body>
        <?php
            $bbuser1 
$bbuserinfo['username'];
            echo 
"You are logged in as $bbuser1.";
        
?>
    </body>
</html>

Returns blank page...

Sketch 01-19-2003 01:35 AM

yup, exactly. change the filename to global2.php and you'll get an error that it can't find the include path. when it's just global.php there's no error so you have the right path and file. Problem is the require()'s. require is similar to include() but when require() returns false it immediatley ends all execution of the php. It just ends.

Now you could replace all the require()'s with include()'s but you'll still get errors because basically the file being called is not inexistence...because it's calling it fropm your external page path and noth the vb page it was meant to be called from. If it was called from a vb page it would return true, but if not, it returns false thus breaking the script. This is also why require() exits. Because the files being require()d are non-existent.

There has to be another way.
Aaron

Davey 01-19-2003 01:38 AM

Well if you understand that, surely you know how to get around it...

Sketch 01-19-2003 04:26 AM

I suppose that's why I'm wasting my time on these forums. :rolleyeyes:

I've just spent the better part of a day importing an ikonboard to vB. I really don't need that.

If I knew what to do I wouldn't be asking.

I mean, sure I could change the require()'s to include()s but that doesn't solve the path problem, and if I fix the path problem it;s bound to cause problems elsewhere.

That's why I'm asking....how would YOU do it? And please, no bull++++ answer. If you don't know, say that. If you do, don't play games, just tell me.

Thanks

Aaron

mr e 01-19-2003 05:14 AM

well if you just want to use the $bbuserinfo variables coudln't you copy the global.php to the folder your using your index.php in? im not sure, just a thought

Sketch 01-19-2003 05:59 AM

wouldn't fix paths. I'd have to copy EVERYTHING over or at leas tthe files it's trying to include. That just doesn't seem like a valid solution to me. :(

Aaron

stryka 01-19-2003 03:17 PM

does the following command solve your problems... it might not cuz i still have probs... see below...

Quote:

<?php
include(getenv('DOCUMENT_ROOT').'/forum/global.php');
?>
.....

I have another question though.... i have includes for my HEADER, STYLES and FOOTER.... i put the above command in my HEADER includes file and nothing shows up... the moment i remove it... then I get the proper output...

here's a quick sample... any ideas what is going wrong? Also... check my final question after this quote...

Quote:

<?
include(getenv('DOCUMENT_ROOT').'/includes/hdrtags-inc.php')
?>
</head>

<!-- <body bgcolor="#B5BECE" id="all" link="#000020" vlink="#000020" alink="#000020"> -->
<!-- OUTSIDE CONTAINER w/ border -->
<table align="center" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#6C8193" width="758">
<tr>
<td>

<!--BEGIN HEADER-->
<table align="center" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="755">
<tr>
<td>
<?
include(getenv('DOCUMENT_ROOT').'/includes/header-inc.php')
?></td>
</tr>
</table>
My Footer tag is just a copy of my VB forum footer... what is the best way to include the variables... how do you write the 'echo' syntax for the following

Quote:

<a title="$bbtitle; ?>" href="index.php?s=$session[sessionhash]">Home</a>&nbsp; |&nbsp;
<a title="Edit your Profile" href="usercp.php?s=$session[sessionhash]">Profile</a>&nbsp; |&nbsp;
<a title="View ChatCon Members." href="memberlist.php?s=$session[sessionhash]">Members</a>&nbsp; |&nbsp;

Link14716 01-19-2003 04:01 PM

Quote:

Originally posted by Sketch
wouldn't fix paths. I'd have to copy EVERYTHING over or at leas tthe files it's trying to include. That just doesn't seem like a valid solution to me. :(

Aaron

Actually, here is a list of files that are needed. These are the ONLY files you'll need to make it work :)

global.php, admin/db_mysql.php, admin/functions.php, admin/sessions.php, admin/config.php

I hope I didn't leave one out. Anyways, those are the files you need. I did the same thing and got my whole site running off vB. :)

stryka 01-19-2003 04:46 PM

so you did multiple includes for each of those files before your HTML? Also, are your non-vb pages outside of the Forum directories?

thanx

Link14716 01-19-2003 04:51 PM

No, you just include global.php and it includes the rest of them. And actually, I used PHP to make it run off the templates instead of hard-coding the HTML into the file, I like that flexibility and power. :D

stryka 01-19-2003 05:00 PM

hmm... ok.. i am willing to try anything to make this work... cuz when I use the include before my HTML, it doesn't load the page or doesn't get the variables... etc... anyhow... I'll gladly throw away the HTML and use templates... but how do you do it?

Can you show a simple example of this in regards to what you mentioned below...

Quote:

actually, I used PHP to make it run off the templates instead of hard-coding the HTML into the file
all the newbies are actively reading this thread so your example will be appreciated...

Davey 01-19-2003 05:05 PM

Yes I'd be interested to know, too Link.
Cheers.

Dave.

Link14716 01-19-2003 05:06 PM

http://www.vggmn.com

Anyways, you don't HAVE to throw away HTML, the thing is, as long as you copy global.php into your main directory and the rest of the files into an admin folder in your main directory, just use
Code:

require ("./global.php");
and put in your HTML. As long as your files were copied right, it will work. :)

Sketch 01-19-2003 06:05 PM

Link, thanks mate. That works perfectly. Now I just have to figure out how to check to see if a user is loggewd on on a non-vb page.

Link14716 01-19-2003 06:53 PM

if ($bbuserinfo[userid]!=0) {
echo "Logged In.";
} else {
echo "Not Logged In.";
}

Davey 01-19-2003 09:22 PM

Link I don't get it.
Can you explain on MSN please mate.
david_james_g_2001@hotmail.com
Thanks.

Dave.

stryka 01-24-2003 11:33 PM

Just a follow-up for the newbies... and a question for the PROS... if you were following the thread... it suggested to move your main files to the root and within an ADMIn folder...

Works great for the PHP files in the root but your sub-folders don't work... cuz of the GLOBAL.php bombing out when it can't find the right paths...

here's the scenario...

Root
- <folder1>
- index.php
- <folder2>
index.php
global.php


both index.php files contain the following:

the root index.php contains
Quote:

<?php require(getenv('DOCUMENT_ROOT').'/global.php')
?>
the root index.php works fine (can echo vb variables) but the index.php within the sub-folder(folder1) does not work and gives me a blank page... and the above environment variable gives you the absolute path...

Unless my syntax is incorrect.. Please let me know what I should be doing different... i have other subfolders that I would have php files that use the global.php... I think i even tried editting the global.php file to include the absolute paths int the file...

Thanx


All times are GMT. The time now is 02:49 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01355 seconds
  • Memory Usage 1,774KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (21)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete