{Semi-Resolved} MyBB 'Variable Scope' 101
Firefox Wins Offline
Member
***
Posts: 164
Joined: Mar 2008
Post: #1
{Semi-Resolved} MyBB 'Variable Scope' 101
Variable Scope may not be the exact term, but the idea is similar.

This doesn't work:*

PHP Code:
define("IN_MYBB", 1);
require_once "./global.php";

// include file *after*  define("IN_MYBB...
require_once "./inc/var/example2.php";


*The variables in './inc/var/example2.php', are not set or available.

This works:*

PHP Code:
// include file before  define("IN_MYBB...
require_once "./inc/var/example2.php";

define("IN_MYBB", 1);
require_once "./global.php";


*The variables in './inc/var/example2.php', are set and available to use.

A) None of the variables in 'example2.php' conflict with MyBB standard vars.
B) The 'disappearing vars' are *not* being used inside a function.
C) How come 'they' cannot be included*** after  define("IN_MYBB", 1);  ?

***I'm certain the above is true in at least one case, any idea why?
Thanks for advice.

(This post was last modified: 09-24-2010 01:21 PM by Firefox Wins.)
09-20-2010 01:32 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: MyBB 'Variable Scope' 101
Most likely because one of your claims is false (my guess is the conflict part; maybe not conflict with variables directly, but sourced inputs are conflicting or similar).

I can't say anything more without a sample.

My Blog
(This post was last modified: 09-20-2010 03:40 PM by ZiNgA BuRgA.)
09-20-2010 03:39 PM
Find all posts by this user Quote this message in a reply
Firefox Wins Offline
Member
***
Posts: 164
Joined: Mar 2008
Post: #3
RE: MyBB 'Variable Scope' 101
Would $global_var1 (for example) cause a conflict since it uses $global before the '_' ? (I had assumed "No" since $global != $global_... )
09-20-2010 04:50 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: MyBB 'Variable Scope' 101
No that should work fine.

My Blog
09-20-2010 05:11 PM
Find all posts by this user Quote this message in a reply
Firefox Wins Offline
Member
***
Posts: 164
Joined: Mar 2008
Post: #5
RE: MyBB 'Variable Scope' 101
With your help, I figured it out now.   Smile

(09-20-2010 03:39 PM)ZiNgA BuRgA Wrote:  ... but sourced inputs are conflicting or similar)...

Of course you are correct, and now I know why:
My original example was over-simplified, I should have mentioned the tasks folder

PHP Code:
// include file located in 'tasks' folder does NOT work (for defining some variables), after define("IN_MYBB...
require_once "./inc/tasks/example2.php";


PHP Code:
// Using the same include file placed in 'myvars' folder *does* work
require_once "./inc/myvars/example2.php";

  • So globals.php, or a related file, 'scans' every file in ./inc/tasks folder, even if the 'task' is not active.
^^^
The above statement must be true, or there is a HUGE hole in my logic.
Thanks again Zinga.
(This post was last modified: 09-20-2010 05:48 PM by Firefox Wins.)
09-20-2010 05:37 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: {Resolved} MyBB 'Variable Scope' 101
It shouldn't, if it's a standard MyBB task file, since all they contain is a function.  They don't even do a IN_MYBB check.

My Blog
09-20-2010 07:18 PM
Find all posts by this user Quote this message in a reply
Firefox Wins Offline
Member
***
Posts: 164
Joined: Mar 2008
Post: #7
RE: {Resolved} MyBB 'Variable Scope' 101
(09-20-2010 07:18 PM)ZiNgA BuRgA Wrote:  It shouldn't, if it's a standard MyBB task file, since all they contain is a function.  They don't even do a IN_MYBB check.

A file with just a few vars is "acting differently" when placed in ./inc/tasks/ vs.
./inc/myvars/
^^^
Not sure exactly why; Thanks for the helpful tips Zinga.
09-21-2010 06:50 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #8
RE: {Resolved} MyBB 'Variable Scope' 101
There are many possible reasons, but MyBB is unlikely to be one of them.

Why can't you post the file?

My Blog
09-21-2010 08:25 AM
Find all posts by this user Quote this message in a reply
Firefox Wins Offline
Member
***
Posts: 164
Joined: Mar 2008
Post: #9
{Semi-Resolved} MyBB 'Variable Scope' 101
(09-21-2010 08:25 AM)ZiNgA BuRgA Wrote:  There are many possible reasons, but MyBB is unlikely to be one of them.

Why can't you post the file?

I usually avoid posting exact domain names (which some of the 'vars' are using), since I'm working on launching a bunch of unique sites all at one time.

PHP Code:
1
2
3
4
5
6
7
8
9
<?php

$local_hub = "example_hub1.com";
$major_hub = "major_hub1.com";
$global_hub = "abc123.com";
$npoints = "234000";
$syncpath = "rsync -av /var/www/html/mysource/ /var/www/html/example_domain.com";

?>


The vars are so basic, I'm surprised they work the one way and not the other; Makes no sense, really...

(This post was last modified: 09-24-2010 01:20 PM by Firefox Wins.)
09-24-2010 01:18 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #10
RE: {Semi-Resolved} MyBB 'Variable Scope' 101
Works perfectly fine here.

PHP Code:
1
2
3
4
5
6
7
8
<?php
define("IN_MYBB", 1);
require_once "./global.php";

// include file *after*  define("IN_MYBB...
require_once "./vars.php";

var_dump($local_hub, $major_hub, $global_hub, $npoints, $syncpath);

http://mybbhacks.zingaburga.com/example.php


My Blog
(This post was last modified: 09-24-2010 01:57 PM by ZiNgA BuRgA.)
09-24-2010 01:56 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: