473,395 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

php include problem

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:

<?php
$sivut = array('something');

if (in_array($_GET['sivu'], $sivut)) {
include ($_GET['sivu'] . '.php');
}
else
{
include('error.php');
}
?>

<a href="index.php?sivu=something">something</a><br>


this works good....
code in something.php:

<?php
$sivut = array('stuff','stuff2');

if (in_array($_GET['sivu'], $sivut)) {
include ($_GET['sivu'] . '.php');
}
else
{
include('error.php');
}
?>

<a href="index.php?sivu=stuff">stuff</a>
<a href="index.php?sivu=stuff2">stuff2</a>
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

Aug 16 '07 #1
13 2253
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? ;-)
^^
Aug 16 '07 #2
Rik
On Thu, 16 Aug 2007 17:48:15 +0200, Ulf Kadner <dr******@gmx.netwrote:
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 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.
That's what his/hers? in_array() statement is for, it is actual filtering
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
Aug 16 '07 #3
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
\<_)
^^
Aug 16 '07 #4
Rik
On Thu, 16 Aug 2007 18:09:02 +0200, Ulf Kadner <dr******@gmx.netwrote:
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 = 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
Aug 16 '07 #5
so my site is safe from hacking? or not?

does anybody have a solution for my broblem with the code?

Aug 16 '07 #6
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/
Aug 17 '07 #7
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:

<?php
$sivut2 = array('stuff','stuff2');

if (in_array($_GET['sivu2'], $sivut2))
{
include ($_GET['sivu2'] . '.php');
}
else
{
include('error.php');
}
?>

<a href="index.php?sivu=something&amp;sivu2=stuff">st uff</a>
<a href="index.php?sivu=something&amp;sivu2=stuff2">s tuff2</a>
--
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/
Aug 17 '07 #8
....
....
<a href="index.php?sivu=something&amp;sivu2=stuff">st uff</a>
<a href="index.php?sivu=something&amp;sivu2=stuff2">s tuff2</a>
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?

Aug 17 '07 #9
thanks Toby. works grate now

Aug 17 '07 #10
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.

Aug 17 '07 #11
Rik
On Fri, 17 Aug 2007 14:22:30 +0200, Heikki <he********@gmail.comwrote:
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.

$sivu = (isset($_GET['sivu']) && !empty($_GET['sivu'])) ? $_GET['sivu'] :
'firstpage';
$sivut = array('something');
if (in_array($ivu, $sivut)) include ($sivu.'.php');

--
Rik Wasmus
Aug 17 '07 #12
Rik
On Fri, 17 Aug 2007 14:28:53 +0200, Rik <lu************@hotmail.comwrote:
if (in_array($ivu, $sivut)) include ($sivu.'.php');
if (in_array($sivu, $sivut)) include ($sivu.'.php');
--
Rik Wasmus
Aug 17 '07 #13
On 17 elo, 15:29, Rik <luiheidsgoe...@hotmail.comwrote:
On Fri, 17 Aug 2007 14:28:53 +0200, Rik <luiheidsgoe...@hotmail.comwrote:
if (in_array($ivu, $sivut)) include ($sivu.'.php');

if (in_array($sivu, $sivut)) include ($sivu.'.php');

--
Rik Wasmus
thanks wery much!
works!

Aug 17 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Yannick Turgeon | last post by:
Oups! I did a typing error in my last post. Fixed. ----------- Hello all, We are currently changing our web server and, in the process, updating PHP version from 4.3.0 to 4.3.5. The problem...
43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
6
by: alan | last post by:
Dear all, I have written my own function by C. And my development platform is W2k with VC6.0. Then I also defined a header file to extern declare this function. After that, I include this...
6
by: atv | last post by:
Alright, i have some questions concerning include files en global variables.I hope someone is willing to answer these. 1).Why is it that if i define a global variable in a file, say main.c, and...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
5
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
0
by: Francois | last post by:
Hi, I think I found a bug with VS, and I've included a project example of the problem I got. I've got a project deep into a set of folders. The project have an additional include library...
3
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include...
6
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file =...
5
by: Tio | last post by:
I have project in MFC(vc++) . There are files and classes: classes:dialog1,dialog2,aaa,bbb ---------------------- main.cpp --------------------- #include "mainfrm.h" #include "dialog1.h"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.