Results 1 to 2 of 2

Thread: Forum integration, small issue with globals

  1. #1
    Warz's Avatar
    Warz is offline Active Member
    Join Date
    Jan 2008
    Posts
    141

    Default Forum integration, small issue with globals

    Hey

    I'm trying to integrate a forum into indexu. I did it once before and was having issues with this same problem, I figured out a solution, but I had a server crash and lost everything I had done and now I just can't figure out what exactly I did!

    I access forum like this:
    http://domain.com/page.php?id=forum

    it is stored at http://domain.com/forum/

    Anyways, the problem is related to globals. Take a look at this simple functions:

    Code:
    $a = 1;
    $b = 2;
    
    function Sum()
    {
       global $a, $b;
       $sum = $a + $b;
       return $sum;
    }
    It's supposed to return 3, however when I access the page via http://domain.com/page.php?id=forum instead of http://domain.com/forum/index.php it returns 0. This happens because the script doesn't take note of the "global". In other words: "global $a" equals 0, when it's supposed to be 1 and "global $b" equals 0 when it's supposed to be 2.

    I KNOW this problem is caused by application.php and most likely the safe_extract function and/or addslashes_deep function, I have stripped the slashes so I think it's safe to assume the problem is the safe_extract function. Now the problem is I don't really remember what it does and how to fix this. Could anyone explain this function to me, I really just don't get it?
    Code:
    function safe_extract($var) {
        static $forbidden = array('_FILES', '_ENV', '_GET', '_POST', '_COOKIE', '_SERVER', '_SESSION', 'GLOBALS');
        while (list($k, $v) = @each($var)) {
          if (!in_array($k, $forbidden)) {
            $GLOBALS[$k] = $v;
          }
          else {
            exit;
          }
        }
      }

  2. #2
    Warz's Avatar
    Warz is offline Active Member
    Join Date
    Jan 2008
    Posts
    141

    Default

    Incase anyone else ever ends up with the same issue this is how I solved it:

    Edit page.php like this:

    Code:
      RunPreFilter(__FILE__);
        
      $bad_templates = array('\.\.', 'http://', 'https://', 'file://', 'php://');
      if (!ereg(implode('|', $bad_templates), $id) && file_exists($theme_path . $id . '.html')) {
        if ($id != 'forum')
        {
            DisplayTemplate($theme_path . $id . '.html');
        }
        else
        {
            DisplayTemplate($theme_path . 'header' . '.html');
            include 'forum/index.php';
            DisplayTemplate($theme_path . 'footer' . '.html');  
        }
      }
      else {
        header("HTTP/1.0 404 Not Found");
        $requested_url = $_SERVER["REQUEST_URI"];
        DisplayTemplate($theme_path . "404.html", "\$requested_url");
      }
    
      RunPostFilter(__FILE__);
    It checks if the id is forum and then displays header, the forum and last it displays footer.

    If there are better solution, don't hesitate to let me know.

    thanks

Similar Threads

  1. Small portal_dir issue
    By Harkster in forum Templates
    Replies: 3
    Last Post: 05-17-2009, 01:47 AM
  2. forum integration
    By Warz in forum Buy, Sell or Trade
    Replies: 12
    Last Post: 02-15-2008, 10:24 AM
  3. Register Globals On. Security Threat?
    By thespursfan in forum v5.x
    Replies: 9
    Last Post: 10-21-2005, 05:17 PM
  4. Two small question
    By salim in forum v5.x
    Replies: 3
    Last Post: 05-30-2002, 11:38 AM

Posting Permissions

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