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.
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?
Re: Restricting global.php
would exactly what you gave me - if i was to just copy and past in into the files work?
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?
Re: Restricting global.php
Quote:
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?
Re: Restricting global.php
Quote:
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 ;)