473,796 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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('somethin g');

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">st uff</a>
<a href="index.php ?sivu=stuff2">s tuff2</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 2298
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('somethin g');

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.n etwrote:
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('somethin g');
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('somethin g');
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.n etwrote:
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('somethin g');
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=stuf f">stuff</a>
<a href="index.php ?sivu=something &amp;sivu2=stuf f2">stuff2</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=stuf f">stuff</a>
<a href="index.php ?sivu=something &amp;sivu2=stuf f2">stuff2</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

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

Similar topics

11
2999
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 we've got is that our way to include some files in other ones is no more working properly. The message we are getting looks like: "PHP Warning: main(..\db.inc.php): failed to open stream: No such file or directory in ..."
43
5131
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 relative NOT to the immediate script that is including it, but is relative to the top-level calling script. In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these...
6
7068
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 header file. The function is stored in C:\temp\myfun.c int func(){ return 1;
6
9580
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 i have also other functions defined in that file, i can use the global in all functions, but once i split up the rest of the function in other files, i cannot use the global? Isn't that strange, all the files compiled should be treated as one...
60
8324
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 associated with this source file For example, in a file hello.c: #include <stdio.h>
5
2512
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 very carefully define the order in which paths are searched with command line options on the compiler. Both can cause problems, especially when dealing with complex software distributions. It occurs ot me that by extending the C include...
0
1213
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 directory which is pretty long and expressed relative to the project (with ..\..\ and directory names).
3
2712
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 directories contain a file named "cppfile1.h". In my main project I #include "cppfile1.h". I rely on the order of paths in additional include directories list to get file cppfile1.h from ProjectA and
6
2128
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file = ...\includes\StaffingHeaders.inc -->" </Script> <%=ClientName%> ****************************************************************************
5
2226
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" #include "dialog2.h"
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10239
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10190
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9057
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4122
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.