|
-
Mar 8th, 2009, 12:54 PM
#1
Thread Starter
Hyperactive Member
Restricting global.php
Hi all,
i have 2 global.php files that conflict.
so this is what i want to do.
on the index file i include header.php now in that header file i want to include global1.php just for that include file, and not the rest of the page.
and for the rest of the page i want to include global2.php without it getting used on header include file.
can this be done?
can someone give me the script for doing it.
Thanks
- Paul
Please Rate If I helped you.
Please remember to mark threads as closed if your issue has been resolved.
-
Mar 8th, 2009, 02:57 PM
#2
Re: Restricting global.php
The only way of doing it is to unset all the variables at the bottom of you header.php file. Preventing access to global variables in the created in the index.php page shouldn't be an issue as long as the variables are declared after the page has been included:
PHP Code:
<?php // header.php include 'global1.php';
/** your code here */
// these variables were declared in global1.php // and destroyed now unset $var1; unset $var2';
?>
PHP Code:
<?php // index.php
include 'header.php';
include 'global2.php';
/* these variables may have been declared in header.php but as long as they are initialized with a value they will be overwritten */ $mainVar1 = 'hello'; $mainVar2 = 'world';
echo($variableFromGlobal2); ?>
PHP Code:
<?php // global2.php // unset any variables prior to initialising them and // initialize all variables prior to using them
@unset $variableFromGlobal2 @unset $anotherVariable
$variableFromGlobal2 = 'apple'; $anotherVariable = 'pie'; ?>
may I ask why it is you are doing this and what you hope to achieve? There may be a more secure / efficient way of doing it.
-
Mar 8th, 2009, 05:05 PM
#3
Thread Starter
Hyperactive Member
Re: Restricting global.php
basicaly i have vbulletin installed on my site. so i can use the loggin system on the entire site, on non vb pages i have
Code:
<?php
$curdir = getcwd ();
chdir('/home/*****/public_html/forum');
require_once('/home/*****/public_html/forum/global.php');
chdir ($curdir);
?>
this allows me to call things like
Code:
If ($vbulletin->userinfo['userid']!=0)
{
include('include/topnavl.php');
} else {
include('include/topnav.php');
}
?>
howefver because i want to include this on a downlaod archive script (phcdl) wich uses its own global.php file yet when there both being called in the same file - i get error 500 internal server error
is there aneasyer wasy of doing this?
Please Rate If I helped you.
Please remember to mark threads as closed if your issue has been resolved.
-
Mar 8th, 2009, 05:24 PM
#4
Thread Starter
Hyperactive Member
Re: Restricting global.php
would exactly what you gave me - if i was to just copy and past in into the files work?
Please Rate If I helped you.
Please remember to mark threads as closed if your issue has been resolved.
-
Mar 8th, 2009, 08:35 PM
#5
Re: Restricting global.php
his code was all just an example of how you might do it.
if you're getting an internal server error when they are just included together, then I'm not sure that you would be able to just unset some variables to make it work. I would suggest trying to build your own from scratch or find a different one that would be a bit more compatible?
Last edited by kows; Mar 8th, 2009 at 09:00 PM.
-
Mar 9th, 2009, 08:38 AM
#6
Re: Restricting global.php
 Originally Posted by Paul_so40
basicaly i have vbulletin installed on my site. so i can use the loggin system on the entire site, on non vb pages i have
Code:
<?php
$curdir = getcwd ();
chdir('/home/*****/public_html/forum');
require_once('/home/*****/public_html/forum/global.php');
chdir ($curdir);
?>
this allows me to call things like
Code:
If ($vbulletin->userinfo['userid']!=0)
{
include('include/topnavl.php');
} else {
include('include/topnav.php');
}
?>
howefver because i want to include this on a downlaod archive script (phcdl) wich uses its own global.php file yet when there both being called in the same file - i get error 500 internal server error
is there aneasyer wasy of doing this?
Why not redirect to the log in page and use the session flag set by vbullitin when the user has logged in?
-
Mar 9th, 2009, 08:39 AM
#7
Re: Restricting global.php
 Originally Posted by Paul_so40
would exactly what you gave me - if i was to just copy and past in into the files work?
I don't want to waste time answing, so give it a try and find out for yourself
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|