Results 1 to 7 of 7

Thread: Restricting global.php

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2008
    Posts
    312

    Question 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.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2008
    Posts
    312

    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.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2008
    Posts
    312

    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.

  5. #5
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    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.

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width