Jump to content


help with navigation code


1 reply to this topic

#1 ethereality

    Young Padawan

  • Members
  • Pip
  • 15 posts

Posted 15 July 2005 - 09:14 PM

I asked someone at WHT to modify the Invano Navigation Script for me. They made it so I could have navigation like this: mysite.com/?folder:test/folder:file:test
and it would include content/test/folder/test.php

The CODE:
<?php
$query = $_SERVER['QUERY_STRING'];
$queries = explode("?",$query);
$q[] = explode(":",$queries[0]);
$_GET = null;
foreach($q as $k => $v)
{
    foreach($v as $a => $b)
    {
        if(!empty($v[$a+1]))
        {
            $_GET[$b] = $v[$a+1];
        }
    }
    
    $new_arr = array();
    foreach($_GET as $k => $v)
    {
        if(!in_array($k,$new_arr))
        {
            $new_arr[$k] = $v;
        }
    }
    
    $_GET = null;
    foreach($new_arr as $k => $v)
    {
        $_GET[$k] = $v;
    }
}

// Security, I guess..
$file = "content/{$_GET['folder']}/{$_GET['file']}.php";
if(file_exists($file))
{
    include($file);
}
else
{
    include("news/show_news.php");
}
?>

But, I get this error:

Quote

Warning: Invalid argument supplied for foreach() in /home/dylan/public_html/core/index.php on line 423

Line 423:
    foreach($_GET as $k => $v)

Also, when I try and goto a page such as, ?folder:adobeps:file:list it doesn't work.

What am I doing wrong here?

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 15 July 2005 - 11:14 PM

try changing
foreach($_GET as $k => $v)
   {
       if(!in_array($k,$new_arr))
       {
           $new_arr[$k] = $v;
       }
   }
To
foreach($_GET as $key => $value)
   {
       if(!in_array($key,$new_arr))
       {
           $new_arr[$key] = $value;
       }
   }

Or just remove the script all together, it's really pointless and offer's no more security then using regular get's.
Now, i have NO idea what Invano is, but seriously, get that same person you had do this, change it to using something more along the lines of ?folder=blah&file=test.php It'll be better for your server in the end.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users