473,378 Members | 1,436 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,378 software developers and data experts.

Is a .php file protected from inclusion in outside domains?

nc
If www.any1.com has a lib\file1.php, can someone at
www.any2.com include the script and access the items
in the script? Is it safely protected, or would we need
to handle such protections ourselves?

I.e.,

<?php include("http://www.any1.com/lib/file1.php");
// misc code which checks the defined variables...
echo(pw);
?>

I don't have a system right at the moment to test this.

Thanks, Ralph.
Dec 3 '05 #1
6 1236
nc wrote:
If www.any1.com has a lib\file1.php, can someone at
www.any2.com include the script


Yes, but only the output of the script would be included. So no php code
available to any2.com.

--
E. Dronkert
Dec 3 '05 #2
On Sat, 03 Dec 2005 17:44:18 GMT, nc <ra***@noone.nowhere> wrote:
If www.any1.com has a lib\file1.php, can someone at
www.any2.com include the script and access the items
in the script? Is it safely protected, or would we need
to handle such protections ourselves?

I.e.,

<?php include("http://www.any1.com/lib/file1.php");
// misc code which checks the defined variables...
echo(pw);
?>

I don't have a system right at the moment to test this.

Thanks, Ralph.


I'm usually putting all my lib files into one directory and protect it
with .htaccess file. So they are inaccessible for outer requests. But even
without it - the remote caller will see only script result output.


--
Exact Meta Search | Major Search Engine http://exactsearcher.com
Web Design Essex | Multimedia | Printing http://nextwave.co.uk
Dec 3 '05 #3
NC
nc wrote:

If www.any1.com has a lib\file1.php, can someone at
www.any2.com include the script
Yes.
and access the items in the script?
No.
include("http://www.any1.com/lib/file1.php");


This is equivalent to

readfile("http://www.any1.com/lib/file1.php");

in that only the script's output (but not its internal environment)
will be captured.

Cheers,
NC

Dec 3 '05 #4
NC wrote:
nc wrote:
If www.any1.com has a lib\file1.php, can someone at
www.any2.com include the script

Yes.

and access the items in the script?

No.

The above it true, but your can also stop them from accessing the
'output' for the script as well. Set a special constant in your calling
PHP scripts and have the included script check for the constant to
insure it is an 'authorized' include.

Calling PHP:

<?php
define("THE_MAGIC_WORDS", TRUE); //Your special constant
require_once("myincludes/included.php');
//the rest of your script here
...

In the included PHP:
<?php
if(!defined("THE_MAGIC_WORDS")){
die("Tisk-tisk! Do you have my permission to use this file?");
}
//the rest of your script here
...

If the server is set up correctly they should never be able to see your
actual code, just the output.
--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Dec 3 '05 #5
nc
Thanks Jonathan and NC. :-)

I completely overlooked the variable's existing only
in the hosting server. So, on to the next issue that
comes up. I imagine that if two domains exist upon
one server, any1.com and any2.com, that the PHP
environments applied to each environment are 100%
independent of each other. Is this correct?

Let's take it one step farther and say any1.com is
permitted to trust any2.com, meaning any2.com gets
access to things on any1.com... I don't even know if
this is really possible on Apache servers, but I've
read that it's possible on Microsoft NT servers. And
even with the trust configured in a manner that provides
execution rights... (maybe this is a per server-type issue
dependent upon a method of installation) are the PHP
environments mutually exclusive and independent of
each other? Is it possible for two domain names to
use a shared install of PHP or is this the way it's done
on all servers (and perhaps this should be an Apache
question concerning this topic)?

I'm trying to get a feel for the security measures required
and appreciate any and all help.

Thanks, Ralph.
Dec 4 '05 #6
NC
nc wrote:

I completely overlooked the variable's existing only
in the hosting server. So, on to the next issue that
comes up. I imagine that if two domains exist upon
one server, any1.com and any2.com, that the PHP
environments applied to each environment are 100%
independent of each other. Is this correct?
It depends on how the server is configured.
I'm trying to get a feel for the security measures required


Then read up on PHP's safe mode:

http://www.php.net/features.safe-mode

Cheers,
NC

Dec 4 '05 #7

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

Similar topics

1
by: Orit | last post by:
I am trying to include html file that resides on other server than the main .php file (landing.php), while this server requires user name-password authentication. I tried 2 options while trying:...
6
by: Sgt. Sausage | last post by:
I know it's not possible, but I need a protected internal interface: protected internal interface ISomeInterface{ // yadda yadda yadda } Basically, I need an interface that is completely...
1
by: Ian Mac | last post by:
Hi, I would like to know how it is possible to receive multi part encoded file uploads when the referer is from outside my domain? In other words, the request is not a post back to the page. ...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
22
by: maxwell | last post by:
I'm having a problem using the XML "include" mechanism, which I think has to do with namespaces. I have an XML file that has a lot of repetition--a sequence of elements that appear multiple...
1
by: Leszek | last post by:
Hi. Is it possible to pass to a script a path to a file which is outside public_html? I have this function : function okno( film ){ gora = screen.height/2-315; lewy = screen.width/2-350;...
16
by: Fir5tSight | last post by:
Hi All, I have a small C#.NET program that is as follows: using System; class A { protected int x = 123; }
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
10
by: lg | last post by:
My site consists of many htm pages and each has a banner with my address and some graphic. Now each html page is something like this: <html> blah blah <div> my logo my address </div>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.