location of include files???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
charp
Forum Commoner
Posts: 85
Joined: Sun Oct 26, 2003 3:00 pm
Location: Rancho Cucamonga, Calif. USA

location of include files???

Post by charp »

This question is similar to one in another current post, but just different enough that I thought it best to make a new topic.

I'll start with the most basic question to see if I can avoid a long drawn out explanation of what I'm trying to do. Here goes...

Is it possible to use an include file, such as:

Code: Select all

include("config.php");
if that file is not located on the same server?

Based on the responses to the other post, the following bits of info may be helpful:

I don't have access to the root folder or to the php.ini file.

Thanks in advance.
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

Hello,

for php files? no, because you'll get only the output when its working
php-> is processed on the server side...

greez pozor
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

If you have PHP => 4.3.0 then you can do require 'http://foo.com/whatever.php'; ... if that's what you mean?
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

Hello,

i think he meant include a file from an other server...

greez Pozor
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Yeah, so require 'http://otherserver.com/foo.php' would do it if otherserver is on another server :o ?
User avatar
charp
Forum Commoner
Posts: 85
Joined: Sun Oct 26, 2003 3:00 pm
Location: Rancho Cucamonga, Calif. USA

Post by charp »

Thanks for the quick replies markl999 and Pozor.

Let's see if I can complicate my questions by one or two degrees.

What if the file is not on a web server, but is located on a LAN file server?

I know this can be done with HTML hyperlinks -- e.g. link to a particular folder on a LAN file server -- only works if you're on the LAN. The problem I'm having is that PHP seems to have its own include_path and the HTML path to the file server doesn't get referenced properly. Also, the LAN file server isn't a web box, so using http:// isn't going to work.

Perhaps now is a good time to better explain why I'm asking these questions...

I'm trying to create an intranet on a web server that can be accessed only by those on the LAN with the proper rights. Specifically speaking, the intranet is for the teachers at my school and I don't want students having access to that intranet. Creating yet another login name and password is far too objectionable, so I'm thinking of tying the access to a PHP required file that is located on our LAN file server, which may be accessed only by teachers when they log in to the network. Students who learn the address of the teacher's intranet won't have access to the required file because students accounts don't have rights to that server, so they'll be locked out.

The web server does have PHP version 4.2.4 installed, so that's why I'm looking for a PHP solution. Any other ideas how I might tackle this problem?

Thanks again!
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

Hello,

first question: no idea sorry.

Why not implement a small loginsystem with multiple user? its so easy to implement this with php and mysql and sessions (php session funktion or selfmade). And when you implement this dont forget the autorissationssystem :-). I've done this and its a good solution for the normal web, and for the lan too.

Or (not a solution that i prefer) when you have static ips (or dhcp with mac table -> static ip) allow only these ip to view the pages.
This is very useful for a solution who provide all LAN user but no extern users... :wink:

greez Pozor
Post Reply