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

calling included remote functions

at one centraldomain.com, I have central.php, which consists of this:
<?php
function square($num)
{ return $num * $num;
}
?>

at outerdomain.com, I have test.php, which consists of this:
<?php
include "http://www.centraldomain.com/central.php";
echo square(4); // outputs '16'.
?>

outerdomain.com/test.php =
"Fatal error: Call to undefined function: square() in blah/blah/test.php on
line 12"

wha'appen'? I thought you could call included functions? Hmm... if I put
central.php on the outerdomain.com, it works. No calling functions from
files included remotely?

--
juglesh


Jul 17 '05 #1
11 3676
I noticed that Message-ID: <Ur********************@comcast.com> from
juglesh contained the following:
No calling functions from
files included remotely?


Absolutely! Think about it.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
juglesh wrote:
wha'appen'? I thought you could call included functions? Hmm... if I put
central.php on the outerdomain.com, it works. No calling functions from
files included remotely?


Think about what's happening. The local server goes to the remote server and
asks for a file with a PHP suffix. The remote server reads the file off the
disk and, because it's a PHP file, executes it. It then delivers to the
local server the result of that execution, exactly as if the file had been
requested by a browser. What result is your central.php file going to
provide when executed? An empty string I think. Not what you want...

--
The email address used to post is a spam pit. Contact me at
http://www.derekfountain.org : <a
href="http://www.derekfountain.org/">Derek Fountain</a>
Jul 17 '05 #3
There's a thread from a while ago that was about this.

http://groups-beta.google.com/group/...c848c4e9417f5/

--
Oli

Jul 17 '05 #4
juglesh wrote:
No calling functions from files included remotely?


If the local server could include a remote php file as the original php
rather than the interpreted php (usually html) then anyone could:

<?php
include('http://www.somedomain.com/db.php');

foreach ($GLOBALS as $k=>$v) { echo "$k => $v"; }
?>

and most likely discover somedomains sql username and password.

More over, if the php service on one server could request a copy of the
code from another, everybody's code would be public.

Robin
Jul 17 '05 #5
It would be fun if something like this happened :) We would have a lot
of "semi-script kiddies"...
Robin wrote:
juglesh wrote:
No calling functions from files included remotely?
If the local server could include a remote php file as the original

php rather than the interpreted php (usually html) then anyone could:

<?php
include('http://www.somedomain.com/db.php');

foreach ($GLOBALS as $k=>$v) { echo "$k => $v"; }
?>

and most likely discover somedomains sql username and password.

More over, if the php service on one server could request a copy of the code from another, everybody's code would be public.

Robin


Jul 17 '05 #6

"Oli Filth" <ca***@olifilth.co.uk> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
There's a thread from a while ago that was about this.

http://groups-beta.google.com/group/...c848c4e9417f5/


hrmm... Well, before I go trying the stuff in that link, let me tell you
what my big plan is.

I have a script that I would like to deploy over several websites. And
if/when I want to tweak the code, I don't want to have to go updating all
the sites. The scripts in question must be run on the 'satellite' sites
(unless of course I want everybody's picture galleries displaying *my* trip
to Disneyland!)

So, how would you go about this? I guess in this circumstance, I could
dream up a way to do it with dreamweaver templates...

oh, ps, I tried including a .inc file like on that thread above, and that
wasn't working either. can you do like getfilecontents, and then spit it
out for php to process? over remote sites(probly not, eh). But that was
early this morning, pre-coffee.

--
thanks, juglesh
Jul 17 '05 #7
I noticed that Message-ID: <ia********************@comcast.com> from
juglesh contained the following:
I have a script that I would like to deploy over several websites. And
if/when I want to tweak the code, I don't want to have to go updating all
the sites. The scripts in question must be run on the 'satellite' sites
(unless of course I want everybody's picture galleries displaying *my* trip
to Disneyland!)


Remember
input->process->output.

In other words you send information to the processing script (e.g.
location of photo directory, number of photos to display or it could
handle database queries). This script then takes that information and
processes it creating and outputting the html necessary to create the
viewing page. If the photo links were absolute there is no reason why
pone script could not serve any number of sites. Security may be an
issue to avoid the script being used by unauthorised users.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8

"Geoff Berrow" <bl@ckdog.co.uk> wrote in message
news:0s********************************@4ax.com...
I noticed that Message-ID: <ia********************@comcast.com> from
juglesh contained the following:
I have a script that I would like to deploy over several websites. And
if/when I want to tweak the code, I don't want to have to go updating all
the sites. The scripts in question must be run on the 'satellite' sites
(unless of course I want everybody's picture galleries displaying *my*
trip
to Disneyland!)


Remember
input->process->output.

In other words you send information to the processing script (e.g.
location of photo directory, number of photos to display or it could
handle database queries). This script then takes that information and
processes it creating and outputting the html necessary to create the
viewing page. If the photo links were absolute there is no reason why
pone script could not serve any number of sites. Security may be an
issue to avoid the script being used by unauthorised users.


the script that will run on the central domain needs to do several readirs,
is_files, etc. Testing with is_file is not working.

satellite domain:
test.php=
include "http://www.centraldomain.com/central.php";

central domain:
central.php=
if
(is_file("http://www.satelitedomain.com/aFileThatExists.php")){
echo "file read";
}else{echo "not read";}

output of satelitedomain.com/test.php= not read

something about
http://us4.php.net/manual/en/functio...r-register.php ?

--
thanks for your time
juglesh

Jul 17 '05 #9
I noticed that Message-ID: <3O********************@comcast.com> from
juglesh contained the following:
the script that will run on the central domain needs to do several readirs,
is_files, etc. Testing with is_file is not working.


From the manual on include:

If "URL fopen wrappers" are enabled in PHP (which they are in the
default configuration), you can specify the file to be included using a
URL (via HTTP or other supported wrapper - see Appendix L for a list of
protocols) instead of a local pathname. If the target server interprets
the target file as PHP code, variables may be passed to the included
file using a URL request string as used with HTTP GET. This is not
strictly speaking the same thing as including the file and having it
inherit the parent file's variable scope; the script is actually being
run on the remote server and the result is then being included into the
local script.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #10

"Geoff Berrow" <bl@ckdog.co.uk> wrote in message
news:75********************************@4ax.com...
I noticed that Message-ID: <3O********************@comcast.com> from
juglesh contained the following:
the script that will run on the central domain needs to do several
readirs,
is_files, etc. Testing with is_file is not working.


From the manual on include:

If "URL fopen wrappers" are enabled in PHP (which they are in the
default configuration), you can specify the file to be included using a
URL (via HTTP or other supported wrapper - see Appendix L for a list of
protocols) instead of a local pathname. If the target server interprets
the target file as PHP code, variables may be passed to the included
file using a URL request string as used with HTTP GET. This is not
strictly speaking the same thing as including the file and having it
inherit the parent file's variable scope; the script is actually being
run on the remote server and the result is then being included into the
local script.


I'm running this on the remote(central) server:
if (is_file("http://www.satelitedomain.com/aFileThatExists.php")){
echo "file read";}

so, why is that IF not true? Well, security, I suppose? The script not
allowed to
know what file exists on another server? Oh, doesn't work to use the
absolute url from the local computer, either. No is_file from http, then.
Probly no readdir either?

I might have to go back to the idea of using .inc files, but I think my
server is weird about them. If I include a .inc nothing happens, if I
include a .xyz it works fine (but exhibits the above behavior).

--
juglesh

Jul 17 '05 #11
juglesh wrote:
I'm running this on the remote(central) server:
if (is_file("http://www.satelitedomain.com/aFileThatExists.php")){
echo "file read";}
The 'http://www.satelitedomain.com/aFileThatExists.php' ain't really a file in
this example, but a stream. is_file() you use on your local filesystem.

No is_file from http, then. Probly no readdir either?
readdir(), if it works, I don't know as I haven't tried that, the result is
depending on the remote server settings, if it's allowed to directory list or
not, at least I don't allow that. As the data from a remote server (over http)
isn't files but streams, so there is a quite high risk that the operation will
fail.

I might have to go back to the idea of using .inc files, but I think my
server is weird about them. If I include a .inc nothing happens, if I
include a .xyz it works fine (but exhibits the above behavior).


Blocking to serve *.inc is a good way to do on a server, as in most cases a
*.inc file would be unprocessed and would be quite a good catch fro people who
wants to ruin something when they read config.inc and see your login and
password for the sql database, I know that some have named their *.inc to
*.inc.php so that the page will be processed and generate a blank page when
remotly read.

If you want to use remote files, then you don't have any other option than
using a none standard extention on the files, so that you wont get the
processed page, but this does mean that other people can read your code and
use the information they find in the files to try to make some harm.
//Aho
Jul 17 '05 #12

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

Similar topics

6
by: Charlie | last post by:
Ok, I have three files: calc.cpp, calc.h, and ui.cpp. I would like to call a function that is located in ui.cpp from main() in calc.cpp. Both files have calc.h included, but when I tried to...
14
by: jj | last post by:
Is it possible to call a remote php script from within Access? I'm thinking something like: DoCMD... http://www.domain.com/scripts/dataquery.php DoCmd.OpenQuery "update_data", acNormal, acEdit...
0
by: Richard Mathis | last post by:
My problem is rather complicated (for me), so I'm going to post my problem here as well as what I've done so far to solve my problem. Any assistance would be appreciated. I originally posted this...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
7
by: Venturer | last post by:
I have a banner script that is included in php on a website but the actual script is hosted on a different site allowing me to only edit one file to update the script. I need to store in a...
1
by: Gerald Klix | last post by:
I read the whol email thread carefully and could not find any sentence by Guido, which states that he does not accept ctypes for the standard library. He just declined to rewrite winreg. Did I miss...
10
tolkienarda
by: tolkienarda | last post by:
hi all i am building a small private school management program and i use alot of the same loops, update statements, and whatnot and i would like to put them all into one php file divided into...
16
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
16
by: Jaco Naude | last post by:
Hi there, This is my first post over here and I hope someone can give me some guidance. I'm trying to embed Python into a Visual C++ 2008 application and I'm getting linker problems. I've...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.