include class from remote site

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
webstyler
Forum Commoner
Posts: 85
Joined: Sat Feb 14, 2004 2:16 am

include class from remote site

Post by webstyler »

Hi

I must include a file that contain a class from remote site.

If I include as .php (include "http://www.**.com/myclass.php) don't work as processed as php

If I include as .inc (include "http://www.**.com/myclass.inc) is ok

BUT

if user visit http://www.**.com/myclass.inc can view my class in the browser and I need that this class is not public and not visibile..

any help ?

thx
ohlaph
Forum Newbie
Posts: 7
Joined: Mon Oct 30, 2006 11:42 pm

Post by ohlaph »

have you tried using require instead of include?
webstyler
Forum Commoner
Posts: 85
Joined: Sat Feb 14, 2004 2:16 am

Post by webstyler »

yes, nothing change

:/
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If the remote parses PHP, there will be no PHP code to return to your local site unless it outputs PHP code itself. Either way, remote inclusion is often a dangerous operation.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Post by kaszu »

If you don't want anyone to see the code of the file you want to include you can do following:
create one more file: myclass2.php
If this file is accessed using "?get=some_secret_code", then output the content of myclass.php using "echo file_get_contents('myclass.php');"

To include the class from remote server use:
include('http://.../myclass2.php?get=some_secret_code');
Post Reply